1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
public void ReceiveCallback(IAsyncResult ar)
{
int read = this.m_sock.EndReceive(ar);
if (read <= 0)
{
Buffer.SetByte(this.readbuf, 0, 0);
this.m_sock.BeginReceive(this.readbuf, 0, this.readbuf.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), null);
return;
}
this.msgsAera.Invoke(new DelegateDisplay(this.DisplayMessage), Encoding.ASCII.GetString(this.readbuf));
Buffer.SetByte(this.readbuf, 0, 0);
this.m_sock.BeginReceive(this.readbuf, 0, this.readbuf.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), null);
}
private void DisplayMessage(string message)
{
this.msgsAera.AppendText(message);
} |