public SocketServer(SocketServerBuilder builder) { this.msgHandle = builder.MsgHandle; this.m_numConnections = builder.MaxConnections; //this.m_receiveBufferSize = builder.ReceiveBufferSize; this.m_listen_port = builder.Port; this.m_ipaddress = builder.Address; m_totalBytesRead = 0; m_numConnectedSockets = 0; // allocate buffers such that the maximum number of sockets can have one outstanding read and //write posted to the socket simultaneously m_bufferManager = new BufferManager(builder.ReceiveBufferSize * builder.MaxConnections * opsToPreAlloc, builder.ReceiveBufferSize); //m_bufferManager = new BufferManager(); m_socketManager = new SocketManager(this); m_readWritePool = new SocketAsyncEventArgsPool(builder.MaxConnections); m_maxNumberAcceptedClients = new SemaphoreSlim(builder.MaxConnections, builder.MaxConnections); }
/// <summary> /// 设置数据处理类,该类型需要实现IMassageHandle接口 /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public SocketServerBuilder WithMassageHandle <T>() where T : IMassageHandle { msgHandle = Activator.CreateInstance <T>(); return(this); }
public SocketBuffer(IMassageHandle msghandle, ClientOption option) { this.msgHandle = msghandle; this.option = option; }