"be consistent" | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
When client calls IO::Socket::INET->new it sends to server TCP packet with SYN flag in it. Since given TCP port on server is in LISTENING state, server immediately replies with SYN,ACK, it is done by kernel, and it doesn't matter that your application is not blocked in accept(2). After receiving SYN,ACK client side treats connection as ESTABLISHED, at this moment connect(2), and consequently IO::Socket::INET->new return. Also client sends ACK to server, upon receiving this ACK server either ignores it if application listen queue is full, or assumes connection ESTABLISHED and places it into application queue, again it doesn't matter what application is doing at the moment. Application queue size is determined by Listen parameter (though maybe not exactly equal to it, e.g. on BSD derived systems if you set Listen to 0 queue size will be 1), which in your case is quite big. Note, that changing Listen doesn't affect client's behaviour, as this parameter is taken into account only upon receiving ACK from client, at which stage client already thinks it is connected. So, your scripts work exactly as I expect. P.S.: Given description is valid for modern Linux and may be slightly different on other systems. P.P.S.: generally you shouldn't bother if server already accepted connection or not, you can just start using socket returned by IO::Socket::INET->new, if connection is not yet accepted you will be blocked in recv(2) or send(2) at some point later. In reply to Re: IO::Socket connect fails to block
by zwon
|
|