bugfix: client trying to write before connection is established

Previously we were performing `connect' asynchronously. If `connect'
takes long enough, the client may attempt to write to an unconnected
socket, breaking things bad.

This commit makes sure we only reply to a connect request after the
connection has been established.