net: fix udp default timeouts

pull/7351/head
Delyan Angelov 2020-12-15 18:31:39 +02:00
parent 3a9034a0d0
commit 3e85c759aa
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 9 additions and 1 deletions

View File

@ -2,6 +2,11 @@ module net
import time import time
const (
udp_default_read_timeout = 30 * time.second
udp_default_write_timeout = 30 * time.second
)
pub struct UdpConn { pub struct UdpConn {
sock UdpSocket sock UdpSocket
@ -33,6 +38,8 @@ pub fn dial_udp(laddr string, raddr string) ?UdpConn {
return UdpConn { return UdpConn {
sock: sock sock: sock
read_timeout: udp_default_read_timeout
write_timeout: udp_default_write_timeout
} }
} }
@ -176,6 +183,8 @@ pub fn listen_udp(port int) ?UdpConn {
return UdpConn { return UdpConn {
sock: s sock: s
read_timeout: udp_default_read_timeout
write_timeout: udp_default_write_timeout
} }
} }

View File

@ -1,5 +1,4 @@
import net import net
import time
fn echo_server(_c net.UdpConn) { fn echo_server(_c net.UdpConn) {
mut c := _c mut c := _c