By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,096 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

Asynchronous socket connection timing issue.

P: n/a
Hello everyone here.

This is my first post in this newsgroup, I hope I won't be to much
off-topic. Feel free to redirect me to any better group.
I am getting strange timing issues when failing to asynchronously connect
sockets on closed or filtered ports, but I'm quite unsure if this is a PHP
issue or my misunderstanding, as it seems that socket streams only wrap
around <sys/socket.h>.

I'm running the latest 5.2.5.5 Windows PHP build downloaded yesterday,
running from the command line without any configuration changed from
default. My code is at http://rafb.net/p/DEwN8J71.html with results at
http://rafb.net/p/cnB4dC80.html
Connecting to an open port seems consistent between synchronous and
asynchronous sockets. Opening the socket is instantaneous, connection
establishes in 0.17 seconds, and closing is fast.

Connecting to a filtered port ends up with a socket timeout, but
asynchronous socket closing blocks for 0.5 second which is quite huge. No
network transfer was captured by Wireshark apart from the initial SYN
packet.

Connecting to a closed port with a synchronous socket times out, with
several retries being sent after the server explicitly refused the
connection with a RST ACK. Why doesn't it simply break after the first try ?

Connecting to a closed port with an asynchronous socket takes the time of a
single try, marking the stream as having had an except in stream_select
after RST ACK was received. But here again, fclose()-ing the resource hangs
for 0.5 second.
Why is that an explicitly refused synchronous connection retries until
timeout ? Why doesn't it cancel instantaneously ?

Why is that closing a failed asynchronous socket takes so much time ? It is
really losing a lot of asynchronous' interest if it hangs that long ?
Note that if I don't explicitly fclose() the resources of failed
asynchronous sockets, the same 0.5 seconds lag appears at the end of the
script execution for each one. I guess PHP cleanly frees resources at
shutdown, but it can reach several seconds when several sockets have failed.

Is there another way than fclose() to clear asynchronous sockets ?
Thank you for any advice.

--
Nicolas Le Gland
Dec 23 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
My code is at http://rafb.net/p/DEwN8J71.html
with results at http://rafb.net/p/cnB4dC80.html
As this temporary hosting expired after 24h, here are both code and log :
http://nicolas.legland.free.fr/attac.../24/stream.zip


Dec 24 '07 #2

P: n/a
Having succeeded in writing the same code using the BSD sockets extension
without any such delay, I filled a bug concerning stream implementation.

http://bugs.php.net/?id=43695

Feel free to reply there.

--
Nicolas Le Gland
Dec 28 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.