Moved the setting of the socket options before the connect().