Raise exceptions on connection issues

Use socket.connect() instead of connect_ex(), so the error is raised if
the port is incorrect since it is currently being lost.  This change
will raise socket.error with errno.ECONNREFUSED during the connect
instead of errno.EPIPE during a send.