Posted to tcl by patthoyts at Wed Mar 18 01:28:07 GMT 2009view raw

  1. package require udp
  2.  
  3. proc Read {sock} {
  4. set data [read $sock]
  5. puts "recv [fconfigure $sock -peer]: [string length $data] '$data'"
  6. }
  7.  
  8. set sock [udp_open 6969]
  9. fconfigure $sock -blocking 0 -buffering none -translation binary
  10. fileevent $sock readable [list Read $sock]
  11.  
  12. # Sending using the tcludp demo app:
  13. # tclsh udpcat.tcl send localhost 6969 PING
  14. # this prints:
  15. # recv 127.0.0.1 52259: 4 'PING'