public Result Send(int bytesSent) { try { BytesToSend -= bytesSent; TransmissionItterator += bytesSent; // Still more to send. if (BytesToSend > 0) { OutboundMessage .Skip(TransmissionItterator) .Take(Buffer.Length) .ToArray() .CopyTo(Buffer, 0); Handler.BeginSend(Buffer, 0, Buffer.Length, SocketFlags.None, SocketMonitor.Send, this); return(Result.Success); } Handler.Shutdown(SocketShutdown.Both); Handler.Close(); // Data sent. return(Result.Success); } catch (Exception e) { Handler.Shutdown(SocketShutdown.Both); Handler.Close(); return(Result.Error(e)); } }