0

I have a tcp socket service MyServ running on the background (using Java, doesn't really matter though), and a web server with php that accesses MyServ using persistent socket (pfsockopen).

The problem is, if one php request stopped for whatever reason, it leaves some un-read data in the persistent socket, and the following php request will get an error when reading this socket.

I wonder how's other services with similar scenario (like php-mysql, php-memcached) dealing with this problem? more specificly, how can php tell that a used persistent socket is clean?

user696495
  • 139
  • 1
  • 6
  • 1
    arent socket 2 way connections ? so if one side crashes , the other one should be able to know about it and deal with it. – mpm Apr 05 '13 at 11:13
  • @mpm: for persistent sockets, a php error doesn't affect the connection. Or there doesn't have to be an error, let's say a bad php script leaves un-read data in the socket, then the next good php request will get bombed. – user696495 Apr 05 '13 at 11:20
  • Nothing good can come from such a persistent socket. Why you just don't open a new socket in every PHP request? I guess a persistent socket works for e.g. php-mysql but in this case there is a C module taking care of the socket, it wouldn't let a PHP crash to leave mysql communication in an inconsistent state. – epx Feb 07 '14 at 19:17

0 Answers0