mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
19 lines
373 B
V
19 lines
373 B
V
|
import net
|
||
|
|
||
|
fn start_socket_udp_server() {
|
||
|
bufsize := 1024
|
||
|
bytes := [1024]byte
|
||
|
s := net.socket_udp() or { panic(err) }
|
||
|
_ := s.bind( 9876 ) or { panic(err) }
|
||
|
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()
|
||
|
}
|