/** * @param buff */ private void DoSend(NetStreamStorage buff) { if (!_client.Connected) { Console.Error.WriteLine("NetStreamSender : can't send. The socket is closed."); } else { buff.Flip(); NetStreamStorage buffer = _packer.PackMessage(buff); NetStreamStorage sizeBuffer = _packer.PackMessageSize(buffer.Capacity); buff.Position = 0; // real sending try { _outStream.Write(sizeBuffer.ToArray(), 0, sizeBuffer.Capacity); _outStream.Write(buffer.ToArray(), 0, buffer.Capacity); _outStream.Flush(); } catch (IOException e) { Console.Error.WriteLine(e.StackTrace); } } }