converting php5 socket functions to php3 socket functions
Posted: Thu Jun 23, 2005 9:18 am
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:
nigma: please read
Posting Code In Forums
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;
}