You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What does 'go version' print?
go version go1.2 linux/amd64
What steps reproduce the problem?
Code: http://play.golang.org/p/TasQabnlRu
1. Create a new *net.TCPConn (using net.Accept)
2. Call File()
3. Close new file
4. Set Read Deadline to 5 seconds
5. Start reading
What happened?
The reading is never finishes. As the result i see the following output:
> New Connection: 127.0.0.1:33079
> Fd: 7
>
What should have happened instead?
> New Connection: 127.0.0.1:33079
> Fd: 7
> Error: read tcp 127.0.0.1:33079: i/o timeout
Please provide any additional information below.
I'm trying to understand why this code sample doesn't work. As i understand, File()
creates a copy of the underlying fd. And the new fd has no effect to the original.
One more thing... If i use only the SetReadDeadline function - timeout doesn't work. But
if i use it in couple with the syscall.SetsockoptTimeval function - it works.
The text was updated successfully, but these errors were encountered:
Switching to nonblock mode for new fd can solve this issue:
> syscall.SetNonblock(int(f.Fd()), true)
Is it necessary to block the original fd during duplicate creation?
See dup and/or fcntl online manual. The duplicated file descritor will point the
original file entry, and some attributes/flags bound to the original file entry will be
shared. In this case, you need to do the following:
1) f2, err := c1.(*net.TCPConn).File()
2) c1.Close()
3) tweak attrs/flags via f2
4) c2, err := net.FileConn(f2)
5) f2.Close()
6) use c2 for network IO
by ilarkin@crystalnix.com:
The text was updated successfully, but these errors were encountered: