#2864 SocketConfig set receive timeout

John Little Tue 16 Nov

I'm trying to set a receive timeout, because SocketOptions is deprecated.

sockConf := SocketConfig.cur.setTimeouts(30min)
listener := TcpListener(sockConf)

but the timeout is ignored. How should this be done?

matthew Tue 16 Nov

Hi John - per the docks for TcpListener.make, the timeouts do not apply to a listener socket. Only receiveBufferSize and reuseAddr. When a socket is accepted, the timeouts from the socket config will be applied to the accepted socket.

John Little Tue 16 Nov

So, are you saying that listener accept timeouts are no longer supported? The docs still say "If this listener's receiveTimeout option is configured, then accept will timeout with an IOErr".

Waiting for the socket to be accepted before applying a timeout is non-functional.

matthew Tue 16 Nov

So, are you saying that listener accept timeouts are no longer supported?

Currently that is the case, but I realize now that is a bug. It was supported prior to the SocketConfig refactor and should be still.

I will look at a fix so that the SocketConfig.receiveTimeout will be applied to the listener socket too and I will updated the docs accordingly. I'll post once that fix is done.

matthew Tue 16 Nov

Ticket promoted to #2864 and assigned to matthew

John Little Tue 16 Nov

Thank you.

I have a workaround, essentially a bash one-liner,

while nc localhost $port <<< "";do sleep $timeout;done &

and the fantom loops, doing its housekeeping, if it gets a blank line.

matthew Wed 17 Nov

Ticket resolved in 1.0.78

The TcpListener receive timeout will now be configured from the SocketConfig.

matthew Wed 17 Nov

Ticket promoted to #2864 and assigned to matthew

Reopened because we are having some internal discussion on how this should work and be implemented. Still shooting for a fix for 1.0.78

matthew Yesterday

Ticket resolved in 1.0.78

Added new SocketConfig.acceptTimeout configuration option to control how long TcpListener.accept() will block waiting for an incoming connection.

listener := TcpListener(SocketConfig.cur.copy { it.acceptTimeout = 30min })
listener.bind(IpAddr("localhost"), 8080)

// block for up to 30 minutes waiting for an incoming connection
socket := listener.accept

Login or Signup to reply.