Asynchronous socket connection timing issue.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nicolas Le Gland

    #1

    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 misunderstandin g, 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



    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

    #2
    Re: Asynchronous socket connection timing issue.

    My code is at http://rafb.net/p/DEwN8J71.htmlAs this temporary hosting expired after 24h, here are both code and log :





    Comment

    • Nicolas Le Gland

      #3
      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.



      Feel free to reply there.

      --
      Nicolas Le Gland


      Comment

      Working...