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; } if (!_eConnResetChecked && !Constants.ECONNRESET.HasValue) { Log.LogWarning("Unable to determine ECONNRESET value on this platform."); _eConnResetChecked = true; } var normalRead = status > 0; var normalDone = status == Constants.ECONNRESET || status == Constants.EOF; var errorDone = !(normalDone || normalRead); var readCount = normalRead ? status : 0; if (normalRead) { Log.ConnectionRead(ConnectionId, readCount); } else { _socket.ReadStop(); Log.ConnectionReadFin(ConnectionId); } Exception error = null; if (errorDone) { handle.Libuv.Check(status, out error); } _rawSocketInput.IncomingComplete(readCount, error); if (errorDone) { Abort(); } }