Initial commit of newLISP.
[newlisp.git] / examples / udp-server.lsp
blob28c2b4ccfe33daaac601bcf743a705963d6ff41b
1 #!/usr/bin/newlisp
3 ; demo server for non-blocking UDP communications
5 ; start this program then start the client udp-client.lsp
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 10001 "localhost" "udp"))
12 (if socket (println "server listening on port " 10001)
13 (println (net-error)))
14 (while (not (net-error))
15 (set 'msg (net-receive-from socket 255))
16 (println "->" msg)
17 (net-send-to (nth 1 msg) (nth 2 msg) (upper-case (first msg)) socket))
19 (exit)
21 ;; eof