Asynchronous socket connection timing issue.

This is a discussion on Asynchronous socket connection timing issue. within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hello everyone here. This is my first post in this newsgroup, I hope I won't be to much off-...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-24-2007
Nicolas Le Gland
 
Posts: n/a
Default Asynchronous socket connection timing issue.

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


Reply With Quote
  #2 (permalink)  
Old 12-24-2007
Nicolas Le Gland
 
Posts: n/a
Default Re: Asynchronous socket connection timing issue.

> 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




Reply With Quote
  #3 (permalink)  
Old 12-28-2007
Nicolas Le Gland
 
Posts: n/a
Default Re: Asynchronous socket connection timing issue.

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


Reply With Quote
  #4 (permalink)  
Old 12-29-2007
ginost7@googlemail.com
 
Posts: n/a
Default Re: Asynchronous socket connection timing issue.

On Dec 24, 1:50*am, "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 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


cant access your code or your results
Reply With Quote
  #5 (permalink)  
Old 01-07-2008
Nicolas Le Gland
 
Posts: n/a
Default Re: Asynchronous socket connection timing issue.

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


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:31 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0