diff --git a/vlib/net/udp.v b/vlib/net/udp.v index 8c4c155336..e98741150f 100644 --- a/vlib/net/udp.v +++ b/vlib/net/udp.v @@ -2,6 +2,11 @@ module net import time +const ( + udp_default_read_timeout = 30 * time.second + udp_default_write_timeout = 30 * time.second +) + pub struct UdpConn { sock UdpSocket @@ -33,6 +38,8 @@ pub fn dial_udp(laddr string, raddr string) ?UdpConn { return UdpConn { 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 { sock: s + read_timeout: udp_default_read_timeout + write_timeout: udp_default_write_timeout } } diff --git a/vlib/net/udp_test.v b/vlib/net/udp_test.v index 0eb3699bd3..adc8be9ef6 100644 --- a/vlib/net/udp_test.v +++ b/vlib/net/udp_test.v @@ -1,5 +1,4 @@ import net -import time fn echo_server(_c net.UdpConn) { mut c := _c