private void StartListeningCallback(object stateObject) { var state = (ListenState)stateObject; try { // First we open a master pipe for incoming worker IPC connections. // Actual socket listening starts only when the first worker connection is accepted. var pipe = new UvPipe(this.Worker.Loop); state.OpenedHandles.Add(pipe); pipe.Bind(this.PipeName); pipe.Listen(128, this.AcceptPipeConnectionCallback, state); state.StartTcs?.TrySetResult(null); } catch (Exception exception) { lock (this.SyncRoot) { this.CloseBaseSocket(); } this.OnConnectionAcceptError(exception); state.StartTcs?.TrySetException(exception); } }
private void AcceptPipeConnectionCallback(UvNetworkStream server, Exception error, object stateObject) { var state = (ListenState)stateObject; try { var workerPipe = new UvPipe(this.Worker.Loop, true); state.OpenedHandles.Add(workerPipe); server.Accept(workerPipe); this.workerPipes.Add(workerPipe); if (this.workerPipes.Count == 1) { // Start listening the TCP socket when we got our first worker base.OnListeningStarted(state); } } catch (Exception exception) { lock (this.SyncRoot) { this.CloseBaseSocket(); } this.OnConnectionAcceptError(exception); state.StartTcs?.TrySetException(exception); } }
private void StartListeningCallback(object stateObject) { var state = (ListenState)stateObject; try { var pipe = new UvPipe(this.Worker.Loop, true); state.OpenedHandles.Add(pipe); pipe.Connect(this.pipeName, this.PipeConnectCallback, state); } catch (Exception exception) { lock (this.SyncRoot) { this.CloseBaseSocket(); } this.OnConnectionAcceptError(exception); state.StartTcs?.TrySetException(exception); } }
public static extern void uv_pipe_pending_instances(UvPipe handle, int count);
public static extern int uv_pipe_pending_count(UvPipe handle);
public static extern void uv_pipe_connect(UvPipeConnectRequest req, UvPipe handle, string name, UvConnectCallback cb);
public static extern int uv_pipe_bind(UvPipe loop, string name);
public static extern int uv_pipe_init(UvLoop loop, UvPipe handle, int ipc);