/// <summary> /// Occurs when a read is performed on the connection. /// </summary> private void OnRead(UvStreamHandle handle, int status) { if (status == 0) { // A zero status does not indicate an error or connection end. It indicates // there is no data to be read right now. // See the note at http://docs.libuv.org/en/v1.x/stream.html#c.uv_read_cb. // We need to clean up whatever was allocated by OnAlloc. _rawSocketInput.IncomingDeferred(); return; } var normalRead = status > 0; var normalDone = status == Constants.ECONNRESET || status == Constants.EOF; var errorDone = !(normalDone || normalRead); var readCount = normalRead ? status : 0; if (!normalRead) { _socket.ReadStop(); this.AbortProcessing(); } Exception error = null; if (errorDone) { handle.Libuv.Check(status, out error); } _rawSocketInput.IncomingComplete(readCount, error); if (errorDone) { Abort(); } }