Initial commit of newLISP.
[newlisp.git] / examples / udp-client.lsp
blobad11f9873e9b1839691f4e3eca2a43cc5d61d557
1 #!/usr/bin/newlisp
3 ; demo client for non-blocking UDP communications
5 ; start the server program udp-server.lsp first
7 ; note, that net-listen in UDP mode only binds the socket
8 ; to the local address, it does not 'listen' as in TCP/IP
9 ; v.1.0
11 (set 'socket (net-listen 10002 "" "udp"))
12 (if (not socket) (println (net-error)))
13 (while (not (net-error))
14 (print "->")
15 (net-send-to "127.0.0.1" 10001 (read-line) socket)
16 (net-receive socket 'buff 255)
17 (println "=>" buff))
19 ; eof