/// <summary> /// Connects to a node by using the given <see cref="EndPoint"/>. /// </summary> /// <param name="ep"><see cref="EndPoint"/> to use</param> public void StartConnect(EndPoint ep) { maxConnectionEnforcer.WaitOne(); SocketAsyncEventArgs connectEventArgs = connectPool.Pop(); connectEventArgs.RemoteEndPoint = ep; connectEventArgs.AcceptSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); StartConnect(connectEventArgs); }
private void StartAccept() { SocketAsyncEventArgs acceptEventArg = acceptPool.Pop(); maxConnectionEnforcer.WaitOne(); if (!listenSocket.AcceptAsync(acceptEventArg)) { ProcessAccept(acceptEventArg); } }