Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6470373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:06:13+00:00 2026-05-25T06:06:13+00:00

Looking for a basic UDP Pipe or redirector. Should of course be able to

  • 0

Looking for a basic UDP Pipe or redirector. Should of course be able to see both

client 2 server and server 2 client data.

Here is what I tried but it fails because I don’t know when to call which Receive..

Say I call

  data = serverUdpClient.Receive(sender)

then I have to reroute this, so I call this

  clientUdpClient.Send(data, data.Length)

Now the line after comes which is proper in TCP Pipe.

  data = clientUdpClient.Receive(sender)..

But I have to.. call this again..

  data = serverUdpClient.Receive(sender)
  clientUdpClient.Send(data, data.Length)

before I can use

  data = clientUdpClient.Receive(sender)..

Pretty much the code flow is all fucked.. because it’s socket is blocking. When I started working on UDP.. all examples say stay away from non-blocking as it’s too advanced for newbie’s trying to work with networking sockets.. I find that statement wrong.. the other way around!.

Public serverUdpClient As System.Net.Sockets.UdpClient
Public clientUdpClient As System.Net.Sockets.UdpClient

Sub runProxy()
    If serverUdpClient IsNot Nothing Then
        serverUdpClient.Close()
        serverUdpClient = Nothing
    End If
    If clientUdpClient IsNot Nothing Then
        clientUdpClient.Close()
        clientUdpClient = Nothing
    End If

    Try
        'Listen for incoming udp connection request.
        serverUdpClient = New UdpClient(New IPEndPoint(IPAddress.Any, Int32.Parse(Int(txtListeningPort.Text))))

        WriteLog("Server started at: " + txtListeningPort.Text)

        Dim data As Byte() = New Byte(1023) {}
        Dim sender As IPEndPoint = New IPEndPoint(IPAddress.Any, 0)

        While True
            data = serverUdpClient.Receive(sender)

            'Connect to server.
            If clientUdpClient Is Nothing Then
                clientUdpClient = New UdpClient(txtIP.Text, Int32.Parse(Int(txtListeningPort.Text)))
                clientUdpClient.Connect(txtIP.Text, Int32.Parse(Int(txtListeningPort.Text)))
            End If

            clientUdpClient.Send(data, data.Length)
            data = clientUdpClient.Receive(sender)

            serverUdpClient.Send(data, data.Length)
        End While
    Catch ex As Exception
        WriteLog("Errors at runProxy @ " + ex.Message)
    End Try
End Sub

Also tried this.. doesn’t work properly.

        While True
            If serverUdpClient.Available > 0 Then
                data = serverUdpClient.Receive(sender)

                'Connect to server.
                If clientUdpClient Is Nothing Then
                    clientUdpClient = New UdpClient(txtIP.Text, Int32.Parse(Int(txtListeningPort.Text)))
                    clientUdpClient.Connect(txtIP.Text, Int32.Parse(Int(txtListeningPort.Text)))
                End If

                clientUdpClient.Send(data, data.Length)
            End If

            If clientUdpClient.Available > 0 Then
                data = clientUdpClient.Receive(sender)

                serverUdpClient.Send(data, data.Length)

            End If

        End While
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:06:14+00:00Added an answer on May 25, 2026 at 6:06 am

    Fixed all I had to do was convert my sender IPEndPoint to the connected instance..

    Here is one without Async.. that I made and it works.. only UDP Proxy on all of google/SO coded in C#.

    Fixed it here is the solution if anyone wants to learn how I fixed it.. Please note this is probably the only UDP Proxy on all of google if you stumbled upon this.. that is coded in C#.. easily ported to VB.NET with online .NET converter

    Be happy this code works 😉

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Net.Sockets;
    using System.Net;
    
    namespace UdpProxy
    {
        class Program
        {
            public static IPEndPoint m_listenEp = null;
            public static EndPoint m_connectedClientEp = null;
            public static IPEndPoint m_sendEp = null;
            public static Socket m_UdpListenSocket = null;
            public static Socket m_UdpSendSocket = null;
    
    
            static void Main(string[] args)
            {
    
                // Creates Listener UDP Server
                m_listenEp = new IPEndPoint(IPAddress.Any, 7900);
                m_UdpListenSocket = new Socket(m_listenEp.Address.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
                m_UdpListenSocket.Bind(m_listenEp);
    
                //Connect to zone IP EndPoint
                m_sendEp = new System.Net.IPEndPoint(IPAddress.Parse("REMOTE_IP_GOES_HERE"), 7900);
                m_connectedClientEp = new System.Net.IPEndPoint(IPAddress.Any, 7900);
    
                byte[] data = new byte[1024];
    
                while (true)
                {
                    if (m_UdpListenSocket.Available > 0)
                    {
    
                        int size = m_UdpListenSocket.ReceiveFrom(data, ref m_connectedClientEp); //client to listener
    
                        if (m_UdpSendSocket == null)
                        {
                            // Connect to UDP Game Server.
                            m_UdpSendSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                        }
    
                        m_UdpSendSocket.SendTo(data, size, SocketFlags.None, m_sendEp); //listener to server.
    
                    }
    
                    if (m_UdpSendSocket != null && m_UdpSendSocket.Available > 0)
                    {
                        int size = m_UdpSendSocket.Receive(data); //server to client.
    
                        m_UdpListenSocket.SendTo(data, size, SocketFlags.None, m_connectedClientEp); //listner
    
                    }
                }
    
    
                // Wait for any key to terminate application
                Console.ReadKey();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a basic code samples of how to upload files to server
Just looking for the first step basic solution here that keeps the honest people
Has anyone here extended LEON3 softcore with custom hw? I'm looking for basic example
So I was just looking for basic examples of reading xml structure data with
I'm looking for the most efficient way to be able to set some basic
I'm looking to graph basic database data in a X Y axis graph. I
I'm pretty new to java programming and am looking to do basic data mappings.
I am looking for basic examples/tutorials on: How to write/compile libraries in C++ (
I'm looking for the basic loop like: for (int i = 0; i <
I'm looking at building basic CMS functionality into our web product and am researching

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.