Modified connection to handle unexpected close

The connection has been changed to read the byte arrays and then
deserialize them using MemoryStream. This is a more elegant solution and
has the secondary benefit of when the stream is unexpectadly closed we
are able to handle this gracefully.