php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30454 Socket not closed if no read/write
Submitted: 2004-10-16 06:09 UTC Modified: 2005-02-21 01:00 UTC
Votes:8
Avg. Score:4.6 ± 0.7
Reproduced:7 of 7 (100.0%)
Same Version:0 (0.0%)
Same OS:5 (71.4%)
From: nightcat at poczta dot onet dot pl Assigned:
Status: No Feedback Package: Sockets related
PHP Version: 5.0.2 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nightcat at poczta dot onet dot pl
New email:
PHP Version: OS:

 

 [2004-10-16 06:09 UTC] nightcat at poczta dot onet dot pl
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-21 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 12:01:31 2024 UTC