|  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
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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
25 - 16 = ?
Subscribe to this entry?

 [2004-10-16 06:09 UTC] nightcat at poczta dot onet dot pl
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:
do {
   if (($msgsock = socket_accept($sock)) < 0) {
       echo "socket_accept() failed: reason: " . socket_strerror($msgsock) . "\n";

} 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


Add a Patch

Pull Requests

Add a Pull Request


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-2023 The PHP Group
All rights reserved.
Last updated: Mon Dec 04 12:01:27 2023 UTC