public override void Connect() { if (State != TransportState.Connected) { State = TransportState.Connecting; if (socket == null) { socket = new TCPSocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Connected += new EventHandler <SocketAsyncEventArgs>(socket_Connected); socket.Sent += new EventHandler <SocketAsyncEventArgs>(socket_Sent); socket.Received += new EventHandler <SocketAsyncEventArgs>(socket_Received); } socket.Connect(endPoint); } }
public override void Suspend() { if ((State != TransportState.Suspending) && (State != TransportState.Suspended)) { State = TransportState.Suspending; socket.IsDeadParrot = true; socket.Connected -= socket_Connected; socket.Sent -= socket_Sent; socket.Received -= socket_Received; socket.Dispose(); socket = null; isFirstSend = true; isFirstReceive = true; State = TransportState.Suspended; } }