public virtual void Connect(string host, int port) { disconnected = false; if (Socket == null) { Socket = SocketManager.CreateTcp(); outQueue = new ConcurrentQueue <IPacket>(); Monitor.Start(); } var task = new SocketConnectTask(host, port); task.Completed += ConnectCompleted; Socket.QueueConnect(task); }
public virtual void Connect(IPEndPoint ep) { disconnecting = false; disconnected = false; if (Socket == null) { Socket = SocketManager.CreateTcp(); outQueue = new ConcurrentQueue <IPacket>(); Monitor.Start(); } var task = new SocketConnectTask(ep); task.Completed += ConnectCompleted; Socket.QueueConnect(task); }
public void QueueConnect(SocketConnectTask task) { lock (connQueue) connQueue.Enqueue(task); }
public static void QueueConnect(this Socket socket, SocketConnectTask task) { task.Socket = socket ?? throw new ArgumentNullException("socket", "socket cannot be null"); task.Exception = null; IO.QueueConnect(task); }