Re: socket question



On May 30, 11:03 am, Alexandre Ferrieux <alexandre.ferri...@xxxxxxxxx>
wrote:
On May 30, 10:36 am, Stuart <bigdak...@xxxxxxx> wrote:



Perhaps somebody can help me understand this behavior..

On host1 inside the tcl shell I type

set s [socket -async host1 19000]

I get an error "couldn't open socket: connection refused". This I
expected
as I have no server listening on host1:19000

On host2 inside the tcl shell I type

set s [socket -async host1 19000]

and I get "sock5". There is still no server listening on host1:19000,
and so I'm
wondering why on host2 I don't get the "couldn't open socket:
connection refused" message?

The reason is that the [socket -async] may fail synchronously on the
local interface (pointing to the same machine), probably due to the OS
optimizing the TCP handshake on the loopback. While when you're
attempting the connection from host2, no such optimization takes
place, and the connect() syscall returns success before getting the
(failed) result from the handshake a finite amount of time later.

-Alex

Thanks. That does make sense. When I removed the -async both the
attempts from
host1 and host2 failed in the same way with the connection refused
message.

Stuart
.



Relevant Pages

  • Re: socket question
    ...  On host1  inside the tcl shell I type ... I get an error "couldn't open socket: ... There is still no server listening on host1:19000, ... wondering why on host2 I don't get the "couldn't open socket: ...
    (comp.lang.tcl)
  • socket question
    ... On host1 inside the tcl shell I type ... I get an error "couldn't open socket: ... On host2 inside the tcl shell I type ... There is still no server listening on host1:19000, ...
    (comp.lang.tcl)