public ServerSocket Start() { Log.InfoFormat("ServerSocket:Start LocalEndPoint:{0}", LocalEndPoint.ToString()); _socket.Bind(LocalEndPoint); _socket.Listen(Backlog); _socket.ReceiveBufferSize = _socketSetting.ReceiveBufferSize; _socket.ReceiveTimeout = _socketSetting.ReceiveTimeout; _socket.SendBufferSize = _socketSetting.SendBufferSize; _socket.SendTimeout = _socketSetting.SendTimeout; AcceptAsync(_acceptSocketAsyncEventArgs); return(this); }
private void ProcessReceive(SocketAsyncEventArgs socketAsyncEventArgs) { if (socketAsyncEventArgs.SocketError != SocketError.Success) { return; } var receiveData = socketAsyncEventArgs.Buffer; Log.InfoFormat("ClientSocket:ProcessConnect--已接收到数据{0}--Offset{1}", socketAsyncEventArgs.AcceptSocket.RemoteEndPoint.ToString(), socketAsyncEventArgs.Offset.ToString()); _bufferPool.Free(receiveData); ExitReceiving(); TryReceive(); }
private void ProcessConnect(SocketAsyncEventArgs socketAsyncEventArgs) { if (socketAsyncEventArgs.SocketError == SocketError.Success) { _tcpConnection = new TcpConnection(socketAsyncEventArgs.ConnectSocket, _socketSetting); _manualResetEvent.Set(); Log.InfoFormat("ClientSocket:ProcessConnect--已连接服务器{0}", socketAsyncEventArgs.ConnectSocket.RemoteEndPoint.ToString()); } else { Log.Error("ClientSocket:ProcessConnect--连接服务错误"); } }