comp.lang.tcl
[Top] [All Lists]

Re: socket question

Subject: Re: socket question
From: Pat Thoyts
Date: Fri, 30 May 2008 11:49:06 GMT
Newsgroups: comp.lang.tcl

Stuart <bigdakine@xxxxxxx> writes:

>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?

With -async you should attach a writable event handler and then check
the socket status when that is called. If a socket fails to open then
it becomes writable and you can check the -error channel configuration
to see how it went.

Are these systems different operating systems? I'm somewhat surprised
you got an immediate failure on one system. I would have expected to
get a socket both times and an error set on the socket channel in the
fileevent.

The wiki has some examples of [fileevent $sock writable]

-- 
Pat Thoyts                            http://www.patthoyts.tk/
To reply, rot13 the return address or read the X-Address header.
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy