SocketManager: improve socket error handling

This fixes the case where the socket is not readable or writable, but has the
socket error flag set. This would previously result in an infinite loop.

It also fixes the case where the read handler disconnects the connection but
the write handler still runs.

I tested this with 'oft --default-timeout 0', which causes the controller to
disconnect at various points in the handshake.
SocketManager: fix sending error when connection has not negotiated a version
OFConnectionManager: do not increment error counter if connection closed

Pushes increment down to where we first detect the error.
Merge into master from pull request #30:
SocketManager error handling fixes (https://github.com/floodlight/indigo/pull/30)