mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
net: add tcp_default_read_timeout and tcp_default_write_timeout and use them consistently
This commit is contained in:
parent
560c21629e
commit
e3a1756b11
9 changed files with 80 additions and 130 deletions
|
@ -3,10 +3,6 @@ import time
|
|||
|
||||
fn echo_server(_c net.UdpConn) {
|
||||
mut c := _c
|
||||
// arbitrary timeouts to ensure that it doesnt
|
||||
// instantly throw its hands in the air and give up
|
||||
c.set_read_timeout(10 * time.second)
|
||||
c.set_write_timeout(10 * time.second)
|
||||
for {
|
||||
mut buf := []byte{ len: 100, init: 0 }
|
||||
read, addr := c.read(mut buf) or {
|
||||
|
@ -23,12 +19,6 @@ fn echo_server(_c net.UdpConn) {
|
|||
fn echo() ? {
|
||||
mut c := net.dial_udp('127.0.0.1:40003', '127.0.0.1:40001')?
|
||||
defer { c.close() or { } }
|
||||
|
||||
// arbitrary timeouts to ensure that it doesnt
|
||||
// instantly throw its hands in the air and give up
|
||||
c.set_read_timeout(10 * time.second)
|
||||
c.set_write_timeout(10 * time.second)
|
||||
|
||||
data := 'Hello from vlib/net!'
|
||||
|
||||
c.write_str(data)?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue