[tkined] udp bind only runs script once - why?

Tim Drury (tim.drury@gtri.gatech.edu)
Mon, 17 Aug 1998 12:41:05 -0400

When I bind an event to a udp port (readable), I only get the binding
to execute once. I use the following command:

udp bind $datasocket readable [UDP_ADC_read $datasocket]

to bind the socket to the procedure below:

proc UDP_ADC_read { datasocket } {

# read packet
set packet [udp receivebinary $datasocket]

# parse the packet
set addr [lindex $packet 0]
set port [lindex $packet 1]
set data [lindex $packet 2]

# extract the data

< some code to read stuff out of $data>
}

NOTE: I changed the source of tnmudp.c and added the "receivebinary"
function because I thought the regular "receive" function didn't
perform well for binary data. For example, when sending reading
signed bytes/int/longs/etc, the "receive" function would return

/xffffffea/xffffffcb/0x12 etc.

instead of

/xea/xcb/x12

which I think is easier to parse. So I rewrote it to return

eacb12

which can be easily read using a format command. I'm new at TCL so
perhaps the first version is best, but I couldn't figure out how to
read it. The think the optimal solution is to pass the binary data
back as _binary_ and use the "binary scan" function to read it, but
I couldn't figure out how to code that.

Anyhow, that is moot compared to the real problem. I cannot get
UDP_ADC_read to execute more than once. I thought, perhaps, that
the binding is reset after it is executed so I added

udp bind $datasocket readable [UDP_ADC_read $datasocket]

to the end of the UDP_ADC_read function. This worked for a few hundred
samples, but I think I blew the stack or something because I believe
UDP_ADC_read was recursing forever.

As I stated, I'm new to TCL, but I searched the archives, FAQ, etc.
but couldn't find a solution.

Any help? I just subscribed to this group and I'm not sure it took,
so could an responses be CC'd to my email address too? Thanks.

-tim

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