examples: fix net_udp_server_and_client.v with latest V and latest net module (listen on 0.0.0.0, and dial to 127.0.0.1) (#19564)

This commit is contained in:
pomid 2023-10-14 17:38:26 +03:30 committed by GitHub
parent d851bbbdca
commit 5f1e6815cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,7 +12,7 @@ fn main() {
mut buf := []u8{len: 100}
if is_server {
println('UDP echo server, listening for udp packets on port: ${port}')
mut c := net.listen_udp(':${port}')!
mut c := net.listen_udp('0.0.0.0:${port}')!
for {
read, addr := c.read(mut buf) or { continue }
println('received ${read} bytes from ${addr}')
@ -23,7 +23,7 @@ fn main() {
}
} else {
println('UDP client, sending packets to port: ${port}.\nType `exit` to exit.')
mut c := net.dial_udp('localhost:${port}')!
mut c := net.dial_udp('127.0.0.1:${port}')!
for {
mut line := os.input('client > ')
match line {