|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46062 pfsockopen() not working properly
Submitted: 2008-09-12 06:26 UTC Modified: 2008-11-03 01:00 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: srtm dot india at gmail dot com Assigned:
Status: No Feedback Package: Sockets related
PHP Version: 5.2.6 OS: Winxpsp2
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-09-12 06:26 UTC] srtm dot india at gmail dot com
I am using Apache 2.2.8 under Winxpsp2
I tried to use the 'pfsockopen' function.
After making the connection, i used 'fwrite' library function to send data to the server more than 50 times. 
But what happen is after receiving 33 messages, the tcp server doesnot receive any messages from the client connected.
ie the php funnction fwrite is not sending no more than 33 messages.
I don't know whether this is a limitation or a bug. all the remaining messages are discarded. but the connection is not thrown away.
I have given here the code for php, I had tested with application tcp server.

Reproduce code:

$server = "";
$port = 2055;
$errormsg = '';
$errorno = 0;
$fp = pfsockopen($server, $port, $errorno, $errormsg, 300);
fwrite($fp, "Data from client");

Expected result:
I should be able to receive all the messages regardless of how many messages i send using the pfsockopen and fwrite funcions.

Actual result:
After sending 33 messages, no messages are sent
i am requesting the page 50 times from the browser, the same connection is reused for sending messages.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-15 00:35 UTC]
Are you sure you're always hitting the same apache child? Persistent connections are per apache process/thread not globally.
 [2008-09-15 05:07 UTC] srtm dot india at gmail dot com
Thanks for ur reply
I could not check that directly, but i am checking in my application server which is in c# .net, i am identifying the client by RemoteEndPoint. But no new tcp connections are made from apache, i am sure the persistent connection is global. 
If it is for per process, there is actually no need for persistent connection. 
I checked this by creating custom library for php using winsock2 library. here also i am facing the same problem, the connection is reused, but after sending 33 messages using send function in winsock2 library fails with no error messages,  I am checking in the app server side for any messages received and counting the number of messages received from a particular client. Up to 33 messages, everything is working fine, after that I am not getting error or success, the same resource is returned
 [2008-10-26 11:23 UTC]
Please try using this CVS snapshot:
For Windows:

 [2008-11-03 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 Jun 25 15:01:32 2024 UTC