Пример #1
0
        private void RecieveCallback(IAsyncResult ar)
        {
            IPEndPoint endpoint = new IPEndPoint(HostIP, 0);

            if (Client != null)
            {
                byte[] data;
                try
                {
                    data = Client.EndReceive(ar, ref endpoint);
                }
                catch (SocketException)
                {
                    Disconnect();
                    return;
                }
                catch (ObjectDisposedException)
                {
                    Disconnect();
                    return;
                }
                Client.BeginReceive(new AsyncCallback(RecieveCallback), null);
                if (HostIP.Equals(endpoint.Address))
                {
                    _reader.ReceivedData(data);
                }
            }
        }