Hello all,

I've got a program (program X) that does the following:

* opens a socket (socket A)
* binds socket A to an address/port (x.x.x.x/1099)

* then opens another socket (socket B), 
* binds socket B to an address/port (x.x.x.x/1100)
* calls listen on socket B
* launches a second program (program Y) with proc_open 
* accepts a connection on socket B (presumably from program Y)
* sends a packet on socket B
* reads a packet from socket B

* listens on socket A    <========== PROBLEM
* accepts a connection on socket A (from whomever is trying to connect)

To be clear, the socket B stuff was just added.  socket A has always
existed and worked just fine.  Each socket resource is stored in a
distinct variable.

Where things go wrong, now that I've added socket B, is when I call
socket_accept() on socket A...

For some reason, the socket_accept($sock) call will not block, even
after I've added an explicit socket_set_block($sock) call immediately
preceding the socket_accept($sock) call.

I don't think there are actually any connections waiting when I call
socket_accept($sock), as the socket_accept call returns false.
Although, the socket_strerror(socket_last_error($sock)) returns
"Success".  This seems like the behavior I would expect if my socket was
set to non-blocking.  

Here are the options, from socket_get_options, for socket A before I
call accept:

Resource id #17 [DEBUG] 0
Resource id #17 [ACCEPTCON]
Resource id #17 [BROADCAST] 0
Resource id #17 [REUSEADDR] 0
Resource id #17 [KEEPALIVE] 0
Resource id #17 [LINGER] l_onoff = 0
Resource id #17 [LINGER] l_linger = 0
Resource id #17 [OOBINLINE] 0
Resource id #17 [SNDBUF] 16384
Resource id #17 [RCVBUF] 87380
Resource id #17 [ERROR] 0
Resource id #17 [TYPE] 1
Resource id #17 [DONTROUTE] 0
Resource id #17 [RCVLOWAT] 1
Resource id #17 [RCVTIMEO] sec = 0
Resource id #17 [RCVTIMEO] usec = 0
Resource id #17 [SNDLOWAT] 1
Resource id #17 [SNDTIMEO] sec = 0
Resource id #17 [SNDTIMEO] usec = 0

It seems to me that the actions I'm taking on socket B are somehow
dirying socket A.  

Anyone know of any problems reported with this?  I'm using PHP 4.3.11.
But, I don't see anything in the changelogs that would indicate
something like this has been fixed since 4.3.11.

Also, when my socket_accept call fails for socket A, I try to close the
socket and re-open it, but (even after calling socket_close) when I try
to bind to the same address/port as I did the first time around,
socket_bind fails and tells me "Address already in use"... (and I try it
repeatedly, sleeping 5 seconds between attempts, and it never becomes
available). 

Any help or pointers would be appreciated.

Thanks,

Bob

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to