2019-08-20 20:52:58 +02:00
|
|
|
import net
|
|
|
|
|
|
|
|
fn start_socket_udp_server() {
|
|
|
|
bufsize := 1024
|
|
|
|
bytes := [1024]byte
|
|
|
|
s := net.socket_udp() or { panic(err) }
|
2020-06-08 00:47:04 +02:00
|
|
|
s.bind( 9876 ) or { panic(err) }
|
2019-08-20 20:52:58 +02:00
|
|
|
println('Waiting for udp packets:')
|
|
|
|
for {
|
|
|
|
res := s.crecv(bytes, bufsize)
|
|
|
|
if res < 0 { break }
|
|
|
|
print('Received $res bytes: ' + tos(bytes, res))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_udp_server() {
|
|
|
|
// start_socket_udp_server()
|
|
|
|
}
|