protected virtual Socket CreateSocket(TcpServiceEndPoint serviceEndPoint) { var socket = new Socket(serviceEndPoint.EndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); socket.Bind(serviceEndPoint.EndPoint); return(socket); }
protected void InitializeAndHandleClientHelper(TcpServiceClientBase client, TcpServiceEndPoint serviceEndPoint, Socket clientSocket, IPEndPoint remoteEndPoint) { client.ClientService = this; client.ClientSocket = clientSocket; client.ClientEndPoint = remoteEndPoint; ThreadPool.QueueUserWorkItem(o => (o as TcpServiceClientBase).OnConnect(), client); }
public ServiceSocket(Socket socket, TcpServiceEndPoint endPoint) { Socket = socket; ServiceEndPoint = endPoint; }
protected abstract void HandleClientSocket(TcpServiceEndPoint serviceEndPoint, Socket clientSocket, IPEndPoint remoteEndPoint);
protected override void HandleClientSocket(TcpServiceEndPoint serviceEndPoint, Socket clientSocket, IPEndPoint remoteEndPoint) { InitializeAndHandleClientHelper(new TClient(), serviceEndPoint, clientSocket, remoteEndPoint); }