Bug #46917 [Opn->Fbk]: Socket handling completely broken

From: Date: Fri, 18 Dec 2020 13:34:06 +0000
Subject: Bug #46917 [Opn->Fbk]: Socket handling completely broken
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231152@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=46917&edit=1

 ID:                 46917
 Updated by:         cmb@php.net
 Reported by:        jost_boekemeier at users dot sf dot net
 Summary:            Socket handling completely broken
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            Streams related
 Operating System:   win32 only
 PHP Version:        5.2.8
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

Is there still something not quite right in any of the actively
supported PHP versions[1]?  If so, please provide a short, self
contained reproduce script[2].

[1] <https://www.php.net/supported-versions.php>
[2] <http://sscce.org/>


Previous Comments:
------------------------------------------------------------------------
[2009-10-26 14:15:25] jost_boekemeier at users dot sf dot net

Err, 5.2.11 still uses the old code, doesn't it?

With 5.3dev, Build Date 	Oct 26 2009 13:56:57, I get:

array(4) { ["type"]=> int(2) ["message"]=> string(346) "fwrite(): It
is not safe to rely on the system's timezone settings. You are *required* to use the
date.timezone setting or the date_default_timezone_set() function. In case you used any of those
methods and you are still getting this warning, you most likely misspelled the timezone identifier.
We selected 'Europe/Paris' for '1.0/no DST' instead"
["file"]=> string(89) "C:\Programme\Apache Software Foundation\Tomcat
6.0\webapps\JavaBridgeTemplate554\test.php" ["line"]=> int(11) }

------------------------------------------------------------------------
[2009-10-26 14:06:52] jost_boekemeier at users dot sf dot net

Using the test above I get:

array(4) { ["type"]=>  int(8) ["message"]=>  string(112) "fwrite():
send of 1 bytes failed with errno=10054 Eine vorhandene Verbindung wurde vom Remotehost geschlossen.
" 

So the bug is still there, I think. pfsockopen should transparently check the socket error code and
allocate a new connection if the previous persistent connection has an error.

I have tested this on Win XP and PHP 5.2.11 download.

------------------------------------------------------------------------
[2009-10-24 00:57:45] srinatar@php.net

hi
 please refer to bug #49447 (http://bugs.php.net/bug.php?id=49447) where I have attempted to resolve
this issue.

 i am not sure, if you tried with php 5.2.11 or with recent snapshot and let me know if this
resolved your issue

------------------------------------------------------------------------
[2009-01-10 16:12:15] jost_boekemeier at users dot sf dot net

Here's a test case:

----------------- TestServer.java ------------------
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;


public class TestServer {

    public static void main(String args[]) throws Exception {
	ServerSocket ss = new ServerSocket (9090);
	System.out.println("accepting connections");
	Socket s = ss.accept();
	System.out.println("got initial request");
	InputStream in = s.getInputStream();
	OutputStream out = s.getOutputStream();
	while (true) {
	    out.write((byte)in.read());
	    out.flush();
	    System.out.println("waiting for next request");
	}
	
    }
    
}
---------TestClient.php--------------
<?php

function dieWithMsg() {
  var_dump(error_get_last());
  exit(1);
}

$errno = null; $errstr = null;
$conn = pfsockopen("127.0.0.1", 9090, $errno, $errstr, 30) or dieWithMsg();
fwrite($conn, "\0") or dieWithMsg();
fread($conn, 1) or dieWithMsg();
echo "done";
exit(0);

?>

------------------------------------

To reproduce this bug on Windows XP and above, start the server with:

  java TestServer

and refresh the

   http://127.0.0.1/TestClient.php

a few times.

Then stop TestServer and start it again.

Refresh 

   http://127.0.0.1/TestClient.php

to get a broken connection from PHP.


I was able to reproduce this bug with yesterday's 5.2 windows snapshot.


Regards,
Jost B?kemeier

------------------------------------------------------------------------
[2009-01-07 20:44:43] felipe@php.net

I changed the EGAIN to EWOULDBLOCK in the checking.

http://news.php.net/php.cvs/55434

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=46917


--
Edit this bug report at https://bugs.php.net/bug.php?id=46917&edit=1


Thread (18 messages)

« previous php.bugs (#231152) next »