timeout is the socket write timeout.
Set timeout for receive calls. 0 means no timeout.
See Implementation