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
Calling a network connection's File() method prevents deadlines from working.
This won't timeout correctly:
c, _ := net.ListenUDP("udp", &net.UDPAddr{IP: net.IP{127, 0, 0, 1}, Port: 9999})
fmt.Println("timing out in 1s")
c.SetReadDeadline(time.Now().Add(time.Second))
// calling File() removes the ability to use deadlines
_, _ = c.File()
buf := make([]byte, 1024)
_, e := c.Read(buf)
fmt.Println(e)
It would be nice if deadlines still worked when a socket is in blocking mode, but if it's not possible this should at least be documented.
The text was updated successfully, but these errors were encountered:
mikioh
changed the title
net: using a conn's File() method breaks deadlines
net: using File methods on Conn/PacketConn disable non-blocking I/O and runtime-integrated network poller's deadline features
Dec 22, 2014
mikioh
changed the title
net: using File methods on Conn/PacketConn disable non-blocking I/O and runtime-integrated network poller's deadline features
net: using File methods on Conn/Listener/PacketConn disable non-blocking I/O and runtime-integrated network poller's deadline features
Dec 22, 2014
I understand, but I think it could use a little more precise wording in the documentation as to what "sets the underlying os.File to blocking mode" implies. I wouldn't expect the runtime to start setting RCVTIMEO and SNDTIMEO, but I also couldn't find an stanza stating exactly what the behavior would be.
mikioh
changed the title
net: using File methods on Conn/Listener/PacketConn disable non-blocking I/O and runtime-integrated network poller's deadline features
net: using File methods on Conn/Listener/PacketConn disables non-blocking I/O and runtime-integrated network poller's deadline features
Dec 23, 2014
Calling a network connection's
File()
method prevents deadlines from working.This won't timeout correctly:
It would be nice if deadlines still worked when a socket is in blocking mode, but if it's not possible this should at least be documented.
The text was updated successfully, but these errors were encountered: