Python socket keepalive setup

I am doing asynchronous network programming with a tornado, I created a socket

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM))

      

and put it in a tornado iostream

iostream = tornado.iostream.IOStream(sock)

      

I wonder if I can establish a "keepalive" socket after this? Is the setting valid after creating the iostream. Thank you in advance.

+3


source to share


1 answer


I'd say it's usually best to set whatever socket options you want before creating the IOStream, but in most cases it's fine to set it up later (as long as the main socket option can be set on a socket that's already bound). As of Tornado 4.0, the only option that IOStream is directly related to is TCP_NODELAY.



+3


source







All Articles