mirror of
https://github.com/vlang/v.git
synced 2025-08-03 17:57:59 -04:00
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:
parent
d851bbbdca
commit
5f1e6815cd
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user