Copy sock/in_stream/out_stream before checking for null

Fixes issue #98

If the connection has been closed then these fields may be null.
optimise RelayConnection read/write

Wait indefinitely for new outgoing messages instead of waking up
4 times a second.

Avoid making multiple copies of byte arrays when reading messages.