converting php5 socket functions to php3 socket functions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mrobertson
Forum Newbie
Posts: 2
Joined: Mon Jun 20, 2005 7:19 am

converting php5 socket functions to php3 socket functions

Post by mrobertson »

I have the following socket functions coded in php5. I need to convert them to php3 which I am assuming is dealing with the fsockopen function. I am new to php coding and was wondering if anyone can help me with this task. Basically I need to go right down the line and get the equivalent function for socket create, socket_bind, socket_listen, socket_accept, socket_read. Can anyone help me with this?



code:

Code: Select all

if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) {
		echo "socket_create() failed. Reason: " . socket_strerror($sock) . "<BR>";
	}

	if (($ret = socket_bind($sock, $address, $port)) < 0) {
		echo "socket_bind() failed. Reason: " . socket_strerror($ret) . "<BR>";
	}

	//Start listening on the socket
	if (($ret = socket_listen($sock, 5)) < 0) {
		echo "socket_listen() failed. Reason: " . socket_strerror($ret) . "<BR>";
	}

	//Accept an incoming connection
	if(($client = socket_accept($sock)) < 0) {
		echo "socket_accept() failed. Reason: " . socket_strerror($ret) . "<BR>";
		break;
	}
nigma: please read :!: Posting Code In Forums :!:
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

Post by method_man »

please use php tags or code tags when posting code
Post Reply