Hello everyone, i have one simple question. How to port forward udp port? I've successfully forwarded tcp port (that was easy), but i just can't understand how i can do this for udp port. Maybe someone can give code example?

ps i'm trying to make 2-way port forwarding ( client <-> forwarder <-> server)
pss here is code (it's only one thing that i found in google) which work only in one way (client -> forwarder -> server), i just don't know how to do it to work in 2 ways

class Program
    {
        public static UdpClient receivingUdpClient;
        public static System.Net.IPEndPoint RemoteIpEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Any, 0);
        static UdpClient udpClient = new UdpClient();
        static System.Net.IPAddress OutputIP = System.Net.IPAddress.Parse("IP");
        static int OutputPort = 1001;
        static int InputPort = 1000;
        static Socket serverSocket;

        static void Main(string[] args)
        {
            udpClient.Connect(OutputIP, OutputPort);
            receivingUdpClient = new System.Net.Sockets.UdpClient(InputPort);
            Byte[] dgram = receivingUdpClient.Receive(ref RemoteIpEndPoint);
            udpClient.Send(dgram, dgram.Length);
            Console.ReadLine();
        }
    }

May be this will help you.

I've found it some time before, it's not that i need. I need to forward udp port without using routers or other hardware.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.