Return to net2o.fs CVS log | Up to [gforth] / gforth |
sendto for UDP added
1: \ Internet 2.0 experiments 2: 3: require unix/socket.fs 4: 5: \ Create udp socket 6: 7: 4242 Constant net2o-udp 8: 9: 0 Value net2o-sock 10: 0 Value net2o-srv 11: 12: : new-server ( -- ) 13: net2o-udp create-udp-server s" w+" c-string fdopen to net2o-srv ; 14: 15: : new-client ( hostaddr u -- ) 16: net2o-udp open-udp-socket to net2o-sock ; 17: 18: $81A Constant maxpacket 19: 20: Create inbuf maxpacket allot 21: 22: : read-a-packet ( -- addr u ) 23: net2o-srv inbuf maxpacket read-socket-from ; 24: 25: : send-a-packet ( addr u -- n ) 26: net2o-sock fileno -rot 0 sockaddr-tmp 16 sendto ;