//CR NUL -> CR •ÏŠ·‚¨‚æ‚Ñ IAC‚©‚ç‚Í‚¶‚Ü‚éƒV[ƒPƒ“ƒX‚̈— private void ProcessBuffer(ByteDataFragment data) { int limit = data.Offset + data.Length; int offset = data.Offset; byte[] buf = data.Buffer; //Debug.WriteLine(String.Format("Telnet len={0}, proc={1}", data.Length, _negotiator.InProcessing)); while (offset < limit) { while (offset < limit && _negotiator.InProcessing) { if (_negotiator.Process(buf[offset++]) == TelnetNegotiator.ProcessResult.REAL_0xFF) { _callback.OnReception(_localdata.Set(buf, offset - 1, 1)); } } int delim = offset; while (delim < limit) { byte b = buf[delim]; if (b == 0xFF) { _negotiator.StartNegotiate(); break; } if (b == 0 && delim - 1 >= 0 && buf[delim - 1] == 0x0D) { break; //CR NULƒTƒ|[ƒg } delim++; } if (delim > offset) { _callback.OnReception(_localdata.Set(buf, offset, delim - offset)); //delim‚ÌŽè‘O‚܂ň— } offset = delim + 1; } }
public void RepeatAsyncRead(IByteAsyncInputStream cb) { _callback = cb; //ƒoƒbƒtƒ@‚ɉ½‚ª‚µ‚©—‚Ü‚Á‚Ä‚¢‚éê‡F //NOTE ‚±‚ê‚ÍAIPoderosaSocket#StartAsyncRead‚ðŒÄ‚ÔƒV[ƒPƒ“ƒX‚ð‚È‚‚µAÚ‘±‚ðŠJŽn‚·‚éuŠÔ(IProtocolService‚̃ƒ\ƒbƒhŒn)‚©‚ç //ƒf[ƒ^–{‘Ì‚ðŽóM‚·‚éŒû‚ð’ñ‹Ÿ‚³‚¹‚é‚悤‚É‚·‚ê‚Îœ‹Ž‚Å‚«‚éB‚µ‚©‚µƒvƒƒOƒ‰ƒ}‚Ì‘¤‚Æ‚µ‚Ä‚ÍAÚ‘±¬Œ÷‚ðŠm”F‚µ‚Ä‚©‚çƒf[ƒ^ŽóMŒû‚ð—pˆÓ‚µ‚½‚¢‚Ì‚ÅA //iPoderosa‚Å‚¢‚¦‚ÎAƒƒOƒCƒ“ƒ{ƒ^ƒ“‚ÌOK‚ð‰Ÿ‚·Žž“_‚ÅAbstractTerminal‚Ü‚Å€”õ‚¹‚˂΂Ȃç‚È‚¢‚Æ‚¢‚¤‚±‚ÆjA‚»‚ê‚æ‚è‚̓f[ƒ^‚ð•Û—¯‚µ‚Ä‚¢‚é‚Ù‚¤‚ª‚¢‚¢‚¾‚낤 if (_buffer != null) { lock (this) { _buffer.Close(); byte[] t = _buffer.ToArray(); _data.Set(t, 0, t.Length); if (t.Length > 0) { _callback.OnReception(_data); } _buffer = null; } } }
private void RepeatCallback(IAsyncResult result) { try { int n = _socket.EndReceive(result); _dataFragment.Set(_buf, 0, n); Debug.Assert(_ownerConnection != null); //‚±‚ê‚ðŒÄ‚Ño‚·‚悤‚É‚È‚é‚܂łɂ̓Zƒbƒg‚³‚ê‚Ä‚¢‚邱‚ÆI if (n > 0) { if (OnReceptionCore(_dataFragment) == GenericResult.Succeeded) { BeginReceive(); } } else if (n < 0) { //WindowsME‚É‚¨‚¢‚Ä‚ÍA‚Æ‚«‚Ç‚«‚±‚±‚Å-1‚ª•Ô‚Á‚Ä‚«‚Ä‚¢‚邱‚Æ‚ª”Šo‚µ‚½B‰º‚ÌErrorCode 995‚Ìê‡‚à“¯—l BeginReceive(); } else { OnNormalTerminationCore(); } } catch (Exception ex) { if (!_ownerConnection.IsClosed) { RuntimeUtil.SilentReportException(ex); if ((ex is SocketException) && ((SocketException)ex).ErrorCode == 995) { BeginReceive(); } else { OnAbnormalTerminationCore(ex.Message); } } } }