Beispiel #1
0
 private static void IPv4_UDPHandler(byte[] packetData)
 {
     UDP.UDPPacket udp_packet = new UDP.UDPPacket(packetData);
     if (udpClients.ContainsKey(udp_packet.DestinationPort) == true)
     {
         DataReceived dlgt = udpClients[udp_packet.DestinationPort];
         if (dlgt != null)
         {
             dlgt(new IPv4EndPoint(udp_packet.SourceIP, udp_packet.SourcePort), udp_packet.UDP_Data);
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Send a UDP packet to a destination device
        /// </summary>
        /// <param name="dest">IP address of destination</param>
        /// <param name="srcPort">Source port</param>
        /// <param name="destPort">Destination port to send data to</param>
        /// <param name="data">Data to be sent</param>
        public static void SendUDP(IPv4Address dest, UInt16 srcPort, UInt16 destPort, byte[] data)
        {
            IPv4Address source = FindNetwork(dest);

            if (source == null)
            {
                Console.WriteLine("Destination Network Unreachable!!");
                return;
            }
            UDP.UDPPacket outgoing = new UDP.UDPPacket(source, dest, srcPort, destPort, data);
            TCPIP.IPv4OutgoingBuffer.AddPacket(outgoing);
        }
Beispiel #3
0
 private static void IPv4_UDPHandler(byte[] packetData)
 {
     UDP.UDPPacket udp_packet = new UDP.UDPPacket(packetData);
     if (udpClients.ContainsKey(udp_packet.DestinationPort) == true)
     {
         DataReceived dlgt = udpClients[udp_packet.DestinationPort];
         if (dlgt != null)
         {
             dlgt(new IPv4EndPoint(udp_packet.SourceIP, udp_packet.SourcePort), udp_packet.UDP_Data);
         }
     }
 }
Beispiel #4
0
 /// <summary>
 /// Send a UDP packet to a destination device
 /// </summary>
 /// <param name="dest">IP address of destination</param>
 /// <param name="srcPort">Source port</param>
 /// <param name="destPort">Destination port to send data to</param>
 /// <param name="data">Data to be sent</param>
 public static void SendUDP(IPv4Address dest, UInt16 srcPort, UInt16 destPort, byte[] data)
 {
     IPv4Address source = FindNetwork(dest);
     if (source == null)
     {
         Console.WriteLine("Destination Network Unreachable!!");
         return;
     }
     UDP.UDPPacket outgoing = new UDP.UDPPacket(source, dest, srcPort, destPort, data);
     TCPIP.IPv4OutgoingBuffer.AddPacket(outgoing);
 }