/// <summary> /// Creates a socket which can be used to accept an incoming connection /// </summary> protected override UvStreamHandle CreateAcceptSocket() { var acceptSocket = new UvTcpHandle(Log); acceptSocket.Init(Thread.Loop, Thread.QueueCloseHandle); acceptSocket.NoDelay(NoDelay); return acceptSocket; }
/// <summary> /// Creates the socket used to listen for incoming connections /// </summary> protected override UvStreamHandle CreateListenSocket() { var socket = new UvTcpHandle(Log); socket.Init(Thread.Loop, Thread.QueueCloseHandle); socket.NoDelay(NoDelay); socket.Bind(ServerAddress); socket.Listen(Constants.ListenBacklog, ConnectionCallback, this); return socket; }
/// <summary> /// Handles an incoming connection /// </summary> /// <param name="listenSocket">Socket being used to listen on</param> /// <param name="status">Connection status</param> protected override void OnConnection(UvStreamHandle listenSocket, int status) { var acceptSocket = new UvTcpHandle(Log); acceptSocket.Init(Thread.Loop, Thread.QueueCloseHandle); acceptSocket.NoDelay(NoDelay); try { listenSocket.Accept(acceptSocket); } catch (UvException ex) { Log.LogError("TcpListenerPrimary.OnConnection", ex); return; } DispatchConnection(acceptSocket); }