Exemplo n.º 1
0
        /// <summary>
        /// Returns a UDP datagram that was sent by a remote host.
        /// </summary>
        /// <param name="tempClient">UDP client instance to use to receive the datagram</param>
        /// <param name="packet">Instance of the recieved datagram packet</param>
        public static void Receive(System.Net.Sockets.UdpClient tempClient, out PacketSupport packet)
        {
            System.Net.IPEndPoint remoteIpEndPoint =
                new System.Net.IPEndPoint(System.Net.IPAddress.Any, 0);

            PacketSupport tempPacket;

            try
            {
                byte[] data_in = tempClient.Receive(ref remoteIpEndPoint);
                tempPacket            = new PacketSupport(data_in, data_in.Length);
                tempPacket.IPEndPoint = remoteIpEndPoint;
            }
            catch (System.Exception e)
            {
                throw new System.Exception(e.Message);
            }
            packet = tempPacket;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Sends a UDP datagram to the host at the specified remote endpoint.
 /// </summary>
 /// <param name="tempClient">Client to use as source for sending the datagram</param>
 /// <param name="packet">Packet containing the datagram data to send</param>
 public static void Send(System.Net.Sockets.UdpClient tempClient, PacketSupport packet)
 {
     tempClient.Send(packet.Data, packet.Length, packet.IPEndPoint);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Sends a UDP datagram to the host at the specified remote endpoint.
 /// </summary>
 /// <param name="tempClient">Client to use as source for sending the datagram</param>
 /// <param name="packet">Packet containing the datagram data to send</param>
 public static async Task Send(UdpClient tempClient, PacketSupport packet)
 {
     await tempClient.Send(packet.Data, packet.Length, packet.IPEndPoint);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Sends a UDP datagram to the host at the specified remote endpoint.
 /// </summary>
 /// <param name="tempClient">Client to use as source for sending the datagram</param>
 /// <param name="packet">Packet containing the datagram data to send</param>
 public static async Task Send(UdpClient tempClient, PacketSupport packet)
 {
     await tempClient.Send(packet.Data, packet.Length, packet.IPEndPoint);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Sends a UDP datagram to the host at the specified remote endpoint.
 /// </summary>
 /// <param name="tempClient">Client to use as source for sending the datagram</param>
 /// <param name="packet">Packet containing the datagram data to send</param>
 public static void Send(System.Net.Sockets.UdpClient tempClient, PacketSupport packet)
 {
     tempClient.Send(packet.Data,packet.Length, packet.IPEndPoint);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Returns a UDP datagram that was sent by a remote host.
        /// </summary>
        /// <param name="tempClient">UDP client instance to use to receive the datagram</param>
        /// <param name="packet">Instance of the recieved datagram packet</param>
        public static void Receive(System.Net.Sockets.UdpClient tempClient, out PacketSupport packet)
        {
            System.Net.IPEndPoint remoteIpEndPoint =
                new System.Net.IPEndPoint(System.Net.IPAddress.Any, 0);

            PacketSupport tempPacket;
            try
            {
                byte[] data_in = tempClient.Receive(ref remoteIpEndPoint);
                tempPacket = new PacketSupport(data_in, data_in.Length);
                tempPacket.IPEndPoint = remoteIpEndPoint;
            }
            catch ( System.Exception e )
            {
                throw new System.Exception(e.Message);
            }
            packet = tempPacket;
        }