public void Start() { try { _socket = new Socket(_endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); _socket.Bind(_endPoint); //Set to SOMAXCONN (0x7FFFFFFF), the underlying service provider will set the backlog to a maximum reasonable value _socket.Listen(0x7FFFFFFF); int loopCount = 0; for (int i = 0; i < _acceptCount; i++) { _socket.BeginAccept(new AsyncCallback(BeginAcceptCallback), this); ThreadPoolEx.LoopSleep(ref loopCount); } } catch (Exception ex) { //log.Fatal(__Res.GetString(__Res.SocketServer_ListenerFail), ex); HandleError(ex); } }
public void Start() { try { this._socket = new System.Net.Sockets.Socket(this._endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); this._socket.Bind(this._endPoint); this._socket.Listen(0x7fffffff); int loopIndex = 0; for (int i = 0; i < this._acceptCount; i++) { this._socket.BeginAccept(new AsyncCallback(this.BeginAcceptCallback), this); ThreadPoolEx.LoopSleep(ref loopIndex); } } catch (Exception exception) { this.HandleError(exception); } }