Added code to wait for the connection to be usable before sending any data (This stopped my read thread from exiting without doing anything all the time)