Re: [tkined] scotty, udp, and multithreadedness?

Juergen Schoenwaelder (schoenw@ibr.cs.tu-bs.de)
Fri, 10 Dec 1999 13:49:49 +0100

>>>>> Matthew Levine writes:

Matthew> I have now decoupled the send and receive side but now I have
Matthew> a new problem.

Matthew> It appears that bindings occur in the global scope. How do I
Matthew> pass the udp channel to a binding if I have more than one udp
Matthew> channel to work with?

This is Tcl basics. I think this is what you are looking for:

proc recv {udp} {
puts [udp receive $udp]
}

proc bind {port} {
set u [udp open $port]
udp bind $u readable [list recv $u ]
}

bind 1234
bind 12345

set s [udp open]
udp send $s localhost 1234 "hello"
udp send $s localhost 12345 "hello"

Note, the udp command is very old (it was the first Tcl command I ever
wrote) and it is not 8-bit clean (since Tcl was not 8-bit clean at
that time). I am currently rewriting it to make use of Tcl_Objs and to
align the command syntax with other Tnm commands. This will also
slightly change the way you do event-driven programming on UDP
sockets. So the example above may need some tweaking with future 8.0.0
versions.

/js

-- 
Juergen Schoenwaelder      Technical University Braunschweig
<schoenw@ibr.cs.tu-bs.de>  Dept. Operating Systems & Computer Networks
Phone: +49 531 391 3289    Bueltenweg 74/75, 38106 Braunschweig, Germany
Fax:   +49 531 391 5936    <URL:http://www.ibr.cs.tu-bs.de/~schoenw/>

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.