Example #1
0
        public IEnumerable <Packet> GetPacketsFromRecievedData(IAsyncResult ar)
        {
            int bytesRead = 0;

            try
            {
                bytesRead = socket.EndReceive(ar);
            }
            catch (SocketException ex)
            {
                Log.Info($"Error reading data from socket: { ex.Message }");
                Open = false;
            }

            if (bytesRead > 0)
            {
                foreach (Packet packet in messageBuffer.GetReceivedPackets(bytesRead))
                {
                    yield return(packet);
                }
            }
            else
            {
                Log.Info("No data found from socket, disconnecting");
                Open = false;
            }
        }
Example #2
0
        public IEnumerable <Packet> GetPacketsFromRecievedData(IAsyncResult ar)
        {
            int bytesRead = 0;

            try
            {
                bytesRead = Socket.EndReceive(ar);
            }
            catch (SocketException)
            {
                Console.WriteLine("Error reading data from socket");
                Open = false;
            }

            if (bytesRead > 0)
            {
                foreach (Packet packet in MessageBuffer.GetReceivedPackets(bytesRead))
                {
                    yield return(packet);
                }
            }
            else
            {
                Console.WriteLine("No data found from socket, disconnecting");
                Open = false;
            }
        }
Example #3
0
        public IEnumerable <Packet> GetPacketsFromRecievedData(IAsyncResult ar)
        {
            int bytesRead = Socket.EndReceive(ar);

            if (bytesRead > 0)
            {
                foreach (Packet packet in MessageBuffer.GetReceivedPackets(bytesRead))
                {
                    yield return(packet);
                }
            }
            else
            {
                Open = false;
            }
        }