For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > January 2008 > Asynchronous socket connection timing issue.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Asynchronous socket connection timing issue.
Nicolas Le Gland

2007-12-23, 10:01 pm

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


Nicolas Le Gland

2007-12-24, 7:01 pm

> 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/atta...2/24/stream.zip




Nicolas Le Gland

2007-12-28, 4:00 am

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


ginost7@googlemail.com

2007-12-29, 7:59 am

On Dec 24, 1:50=A0am, "Nicolas Le Gland" <nicolas.legl...@free.fr>
wrote:
> 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 athttp://rafb.net/p/DEwN8J71.htmlwith results athttp:/=

/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 hang=

s
> 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 i=

s
> 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 faile=

d.
>
> Is there another way than fclose() to clear asynchronous sockets ?
>
> Thank you for any advice.
>
> --
> Nicolas Le Gland


cant access your code or your results
Nicolas Le Gland

2008-01-07, 7:01 pm

> cant access your code or your results

As this temporary hosting expired after 24h, here are both code and log :
http://nicolas.legland.free.fr/atta...2/24/stream.zip


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com