1 # Example of sending from an unconnected ipv6 socket
3 set s [socket -ipv6 dgram]
5 foreach i [range 1 5] {
6 # Specify the address and port with sendto
7 $s sendto "$i + $i + 10" {[::1]:20000}
9 # Receive the response - max length of 100
10 puts [$s recvfrom 100]
15 # Now sending via a connected udp socket
17 set s [socket -ipv6 dgram {[::1]:20000}]
19 foreach i [range 5 10] {
20 # Socket is connected, so can just use puts here
21 # But remember to flush to ensure that each message is separate
22 $s puts -nonewline "$i * $i"
25 # Receive the response - max length of 100
26 puts [$s recvfrom 100]