You should use ns_socklistencallback like this:

ns_socklistencallback $address $port $serverProc

serverProc = (for example):
proc ::tclbean::server::timedPush { read write } {
    ns_log Notice "::tclbean::server::timedPush about to read data"
    set NVList [split [gets $read]]
    ns_log Notice "::tclbean::server::timedPush found '$NVList'"
    puts $write "OK"

    flush $write
    close $read
    close $write
    set PushFrequency [lindex $NVList 0]
    set NVData [lrange $NVList 1 end]
    ns_schedule_proc -thread $PushFrequency ::tclbean::server::Push $NVData     
 
    
}

So you have to define the proc to accept read write and use those to manage 
the socket.


A full example is at:
http://rmadilo.com/m2/servers/rmadilo/modules/tcl/twt/packages/tclbean/tcl/tclbean-procs.tcl




On Monday 26 February 2007 08:35, Michael Andrews 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.  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?
>
> I could use ns_socklisten and ns_sockcallback, but I have had a hard
> time keeping the socket open after the first connection. My callback
> exits and so does the socket.  I could use a while loop - but if I
> can get the socket Id opened by ns_socklistencallback it would be
> cleaner.
>
> Thanks,
> M
>
>
> --
> 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.


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