public void Accept() { IntPtr bytePointer = Marshal.UnsafeAddrOfPinnedArrayElement( _byteBuffer.Array, _byteBuffer.End); if (null == _socket) { _socket = _acceptor.CreateSocket(_listenSocket.AddressFamily , _listenSocket.SocketType, _listenSocket.ProtocolType); } int bytesTransferred; if (_listenSocket.AcceptEx(_socket, bytePointer , 0 //_byteBuffer.Space - (HazelAddress.MaxSize + 4) * 2 //必须为0,否则会有大量的连接处于accept中,因为客户端只 //建立连接,没有发送数据。 , HazelAddress.MaxSize + 4 , HazelAddress.MaxSize + 4 , out bytesTransferred , NativeOverlapped)) { return; } if ((int)SocketError.IOPending == Marshal.GetLastWin32Error()) { return; } throw new AcceptError(_acceptor.BindPoint, new SocketException()); }