On 2007.02.26, Michael Andrews <[EMAIL PROTECTED]> wrote:
> I am using ns_socklistencallback to open a socket and run a proc when  
> new connections arrive.  It works great and makes socket programming  
> very easy - but - It does not return the socket Id.

Right, what would it return?  It sets up a callback ...

Your callback script gets passed two Tcl channels--presumably, one for
input, one for output:

    nscp> ns_eval {{proc ::socklistencallback args { ns_log notice 
"socklistencallback: [list $args]" }}}

    nscp> ns_socklistencallback 127.0.0.1 1234 ::socklistencallback

    $ telnet localhost 1234
    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.
    Connection closed by foreign host.

    $ tail server.log | grep socklistencallback
    [26/Feb/2007:13:37:50][12034.2800360368][-socks-] Notice: 
socklistencallback: {sock54 sock56}

> I would like to  be able to close the socket at some point.  Any
> advice on how to get  the socket Id created by this proc?

Are you trying to close the socket from within the callback script, or
from another thread?

Closing it from the callback script should be pretty straightforward,
like [close $rfd] and [close $wfd].  Closing it from another thread will
mean implementing some simple inter-thread communication mechanism.

Yes, it'd be nice if there were a standard, sane and safe inter-thread
messaging API.

-- Dossy

-- 
Dossy Shiobara              | [EMAIL PROTECTED] | http://dossy.org/
Panoptic Computer Network   | http://panoptic.com/
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to