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
|
@ -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}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue