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:
@ -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}
|
||||
|
Reference in New Issue
Block a user