public void Bind() { _listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); var localEndPoint = new IPEndPoint(_bind.IpAddress, _bind.Port); _listenSocket.Bind(localEndPoint); _listenSocket.Listen((int)_bind.MaximumPendingConnections); _manualResetEvent = new ManualResetEvent(false); _manualResetEvent.Reset(); _connectionWorkersPool = _connectionWorkersPoolFactory.GetSocketAsyncEventArgsPool( _bind.MaximumOpenedConnections, (uint)Environment.SystemPageSize, IoCompleted); var acceptEventArg = new SocketAsyncEventArgs(); acceptEventArg.Completed += AcceptEventArg_Completed; _manualResetEvent.WaitOne(); if (_listenSocket.AcceptAsync(acceptEventArg)) // if performed synchroniosly { ProcessAccept(acceptEventArg); } }
public void Bind() { _listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); var localEndPoint = new IPEndPoint(_bind.IpAddress, _bind.Port); _listenSocket.Bind(localEndPoint); _listenSocket.Listen((int) _bind.MaximumPendingConnections); _manualResetEvent = new ManualResetEvent(false); _manualResetEvent.Reset(); _connectionWorkersPool = _connectionWorkersPoolFactory.GetSocketAsyncEventArgsPool( _bind.MaximumOpenedConnections, (uint)Environment.SystemPageSize, IoCompleted); var acceptEventArg = new SocketAsyncEventArgs(); acceptEventArg.Completed += AcceptEventArg_Completed; _manualResetEvent.WaitOne(); if (_listenSocket.AcceptAsync(acceptEventArg)) // if performed synchroniosly { ProcessAccept(acceptEventArg); } }