private void HandleReceive(AsyncSocket sender, byte[] buffer, int HeadPointer, int BufferSize, int BytesRead, IPEndPoint source, IPEndPoint remote) { HTTPMessage msg = HTTPMessage.ParseByteArray(buffer, 0, BufferSize); msg.LocalEndPoint = source; msg.RemoteEndPoint = remote; sender.BufferBeginPointer = BufferSize; if (this.OnReceive != null) { this.OnReceive(this, msg); } }
private void HandleReceive(IAsyncResult result) { try { int count = this.ReceiveSocket.EndReceiveFrom(result, ref this.R_Ep); HTTPMessage msg = HTTPMessage.ParseByteArray(this.MainBuffer, 0, count); msg.LocalEndPoint = this.LocalIPEndPoint; msg.RemoteEndPoint = new IPEndPoint(((IPEndPoint)this.R_Ep).Address, ((IPEndPoint)this.R_Ep).Port); this.ProcessPacket(msg, msg.RemoteEndPoint); } catch (Exception) { } try { this.ReceiveSocket.BeginReceiveFrom(this.MainBuffer, 0, 0x1000, SocketFlags.None, ref this.R_Ep, new AsyncCallback(this.HandleReceive), null); } catch (Exception) { } }