note 44021 added to function.socket-accept
| From: | gn_mnit at yahoo dot com | Date: | Mon, 12 Jul 2004 19:48:32 +0000 |
| Subject: | note 44021 added to function.socket-accept | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-73114@lists.php.net to get a copy of this message | ||
i'm new to php, can anyone help me on this 'server socket'
<?php
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); // Create our socket.
socket_bind($socket,'localhost',15000); //bind the socket to our IP address, on port
.......
socket_listen($socket); // listen for any incoming connections
while($connection = socket_accept($socket)) // accept any incoming connection and write to the
socket.
{
socket_write($connection,'You\'ve successfully connected to my computer!\r\n');
$res=socket_recv($socket,$buffer,1024,0);
if ($res<=0){
echo "error";
}
else echo $res;
}
socket_close( $socket );
?>
i'm getting different errors at different times, i'm stuck up.
Warning: socket_bind() unable to bind address [0]: Only one usage of each socket address
(protocol/network address/port) is normally permitted. in c:\apache\apache\htdocs\final\server.php
on line 3
Warning: socket_listen() unable to listen on socket [0]: An invalid argument was supplied. in
c:\apache\apache\htdocs\final\server.php on line 4
Warning: socket_accept() unable to accept incoming connection [0]: An invalid argument was supplied.
in c:\apache\apache\htdocs\final\server.php on line 5
Warning: socket_accept() unable to accept socket connection [0]: The operation completed
successfully. in c:\apache\apache\htdocs\final\server.php on line 5
----
Manual Page -- http://www.php.net/manual/en/function.socket-accept.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44021
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44021&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44021&report=yes
Search -- http://master.php.net/manage/user-notes.php