diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-08-12 12:21:18 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-10-15 11:02:50 +1000 |
commit | 0f4cb39eb1ebaf3cc931b450b517a177beb8c05e (patch) | |
tree | 288021a44441ecc21e785641c507eff7dbe707d6 /examples/udp2.client | |
parent | 2077c587650b0ff0332ceaacece892e38e1c436a (diff) | |
download | jimtcl-0f4cb39eb1ebaf3cc931b450b517a177beb8c05e.zip jimtcl-0f4cb39eb1ebaf3cc931b450b517a177beb8c05e.tar.gz jimtcl-0f4cb39eb1ebaf3cc931b450b517a177beb8c05e.tar.bz2 |
Make udp sockets useful
Separate socket types: udp client and udp server
Allow client sockets to 'connect' to an address
Allow server sockets to 'bind' to an address
Add support for 'sendto' and 'recvfrom'
Add socket client and server examples
Document new udp sockets
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'examples/udp2.client')
-rw-r--r-- | examples/udp2.client | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/examples/udp2.client b/examples/udp2.client new file mode 100644 index 0000000..776dc2c --- /dev/null +++ b/examples/udp2.client @@ -0,0 +1,13 @@ +# Example of sending via a connected udp socket + +set s [socket dgram 127.0.0.1:20000] + +foreach i [range 1 20] { + # Socket is connected, so can just use puts here + # But remember to flush to ensure that each message is separate + $s puts -nonewline "$i * $i" + $s flush + + # Receive the response - max length of 100 + puts [$s recvfrom 100] +} |