1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net: add tcp_default_read_timeout and tcp_default_write_timeout and use them consistently

This commit is contained in:
Delyan Angelov
2020-12-15 17:39:11 +02:00
parent 560c21629e
commit e3a1756b11
9 changed files with 80 additions and 130 deletions

View File

@ -7,10 +7,6 @@ const (
fn handle_conn(_c net.TcpConn) {
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 := c.read(mut buf) or {
@ -39,10 +35,6 @@ fn echo() ? {
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)?
mut buf := []byte{len: 4096}