Re: [tkined] UDP bind problem

From: Juergen Schoenwaelder (
Date: Thu Jun 22 2000 - 15:47:38 MET DST

>>>>> Irina Brubaker writes:

Irina> Hi all, I am using scotty2.1.10 tnm package to send and receive
Irina> udp datagrams. When I had a simple program without udp bind,
Irina> it worked just fine. Though if the server of the udp socket
Irina> was dead, the program on the client blocked on the udp receive
Irina> forever. I thought I would try the 'udp bind $f readable
Irina> [script]'. I am hoping to be able to return from the function
Irina> if nothing is readable (if the server is dead). Below is the
Irina> code which does not work. I know it sends correctly, but does
Irina> not receive back anything. Please let me know what I am doing
Irina> wrong.

You have to force the interpreter into the event loop. The after 10000
command just blocks and does not process any events. So change that

        after 10000 udp close $u

which will close the udp socket after 10 seconds. Now, at the end of
the script, call

        vwait forever

which forces the interpreter to enter the event loop. (You may want
to wait for something more reasonable - see the vwait documentation.)
There is also a syntax bug in the recv procedure. Change it to:

proc recv { f } {
    # get packet
    if {[catch {udp receive $f} packet]} {
        udp close $f
        puts "Error while receiving: $packet"
    # ....


Juergen Schoenwaelder      Technical University Braunschweig
<>  Dept. Operating Systems & Computer Networks
Phone: +49 531 391 3289    Bueltenweg 74/75, 38106 Braunschweig, Germany
Fax:   +49 531 391 5936    <URL:>

-- !! 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 <>. !! See for more information.

This archive was generated by hypermail 2b29 : Mon Jan 08 2001 - 15:27:47 MET