Free'ing Sockets Error
| From: | Adam Voigt | Date: | Wed, 30 Jul 2003 13:33:52 +0000 |
| Subject: | Free'ing Sockets Error | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-157519@lists.php.net to get a copy of this message | ||
I cannot make PHP release the port after it binds
to it, the following script should just open a
port, accept one line of input, write the contents
to the out file, then unbind and close the connection.
It works fine, with the exception of if I run it
again, it reads the port as still being bound. Any
ideas on how to fix my script, or atleast free the
port without having to reboot?
<?php
define('IP','127.0.0.1');
define('PORT','23');
$s = socket_create(AF_INET,SOCK_STREAM,0);
socket_bind($s,IP,PORT);
socket_listen($s);
$f = fopen('out','w');
$a = socket_accept($s);
fwrite($f,socket_read($a,1000));
fclose($f);
socket_shutdown($a);
socket_close($a);
socket_shutdown($s);
socket_close($s);
?>
--
Adam Voigt (adam@cryptocomm.com)
Linux/Unix Network Administrator
The Cryptocomm Group