From:             nightcat at poczta dot onet dot pl
Operating system: Linux
PHP version:      5.0.2
PHP Bug Type:     Sockets related
Bug description:  Socket not closed if no read/write

Description:
------------
I'm playing with Socket support in PHP 5, and found something weird.

I was writing my own classess for Socket support and done a base:
1) create serversocket
2) create clientsocket on serversocket->accept()
3) close clientsocket
4) close serversocket

but if between point 2 and 3 there was no read/write for socket, next try
to start a program ended an error.

Below here is a part of code for server (from php documentation).
I just removed everything between socket_accept and socket_close() and
added a counter to skip from loop after 3 connections.

Reproduce code:
---------------
$inc=0;
do {
   if (($msgsock = socket_accept($sock)) < 0) {
       echo "socket_accept() failed: reason: " . socket_strerror($msgsock)
. "\n";
       break;
   }

   socket_close($msgsock);
   $inc++;
   
   
} while ($inc<3);

Expected result:
----------------
Program should close all used sockets and run for the second time
normally.

Actual result:
--------------
Running example from php documentation with the msgsocket part switched
with provieded example for the second time results in 

Warning: socket_bind(): unable to bind address [98]: Address already in
use in /server/www/data/thot/tests/simple-server.php on line 19

-- 
Edit bug report at http://bugs.php.net/?id=30454&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30454&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30454&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30454&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30454&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30454&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30454&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30454&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30454&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30454&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30454&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=30454&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=30454&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30454&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30454&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30454&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30454&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30454&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30454&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30454&r=mysqlcfg

Reply via email to