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 6532011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:56:52+00:00 2026-05-25T09:56:52+00:00

I get this error.. and I know the ip address is not valid duh!

  • 0

I get this error.. and I know the ip address is not valid duh! but it’s a server it should be based on port only.

Error =

Errors at runProxy @ The requested address is not valid in its context
0.0.0.0:7900

Can someone tell me what I did wrong?

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))))
        clientUdpClient = New UdpClient(txtIP.Text, 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
            Application.DoEvents()
            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.Connect(New IPEndPoint(IPAddress.Any, Int32.Parse(Int(txtListeningPort.Text))))
                serverUdpClient.Send(data, data.Length)

            End If

        End While
    Catch ex As Exception
        WriteLog("Errors at runProxy @ " + ex.Message)
    End Try
End Sub

P.S.> my client I connect to 127.0.0.1 : 7900..

I want it to re-route the connection to the txtIP.text : 7900 (txtListeningPort.Text)

  • 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-25T09:56:52+00:00Added an answer on May 25, 2026 at 9:56 am

    Here is a working
    TCP or UDP Redirector / UDP Proxy / UDP Pipe / TCP Proxy / TCP Pipe

    I created many different models of UDP Proxy connection bouncers and they all seem to loose connection using the standard Sockets class, but using UDPClient classes this problem completely went away.

    The UDP Proxy is only 25 lines of code but the power and stability is off the charts

    Below is examples how to do it in both TCP and UDP

    C# Code below

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net.Sockets;
    using System.Diagnostics;
    using System.Net;
    using System.Threading;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                string Address= "*PUT IP ADDRESS HERE WHERE UDP SERVER IS*";
                int UDPPort = *PUT UDP SERVER PORT HERE*;
                UdpRedirect _UdpRedirect = new UdpRedirect() { _address = Address, _Port = UDPPort};
                Thread _Thread = new Thread(_UdpRedirect.Connect);
                _Thread.Name = "UDP";
                _Thread.Start();
    
                int TCPPort = *PUT TCP PORT HERE FOR TCP PROXY*;       
                TcpRedirect _TcpRedirect = new TcpRedirect(Address, TCPPort);            
            }
        }
        class UdpRedirect
        {
            public string _address;
            public int _Port;
            public UdpRedirect()
            {
            }
    
            public void Connect()
            {
                UdpClient _UdpClient = new UdpClient(_Port);
                int? LocalPort = null;
                while (true)
                {
                    IPEndPoint _IPEndPoint = null;
                    byte[] _bytes = _UdpClient.Receive(ref _IPEndPoint);
                    if (LocalPort == null) LocalPort = _IPEndPoint.Port;
                    bool Local = IPAddress.IsLoopback(_IPEndPoint.Address);
                    string AddressToSend = null;
                    int PortToSend = 0;
                    if (Local)
                    {
                        AddressToSend = _address;
                        PortToSend = _Port;
                    }
                    else
                    {
                        AddressToSend = "127.0.0.1";
                        PortToSend = LocalPort.Value;
                    }
                    _UdpClient.Send(_bytes, _bytes.Length, AddressToSend, PortToSend);
                }
            }
        }
        class TcpRedirect
        {
            public TcpRedirect(string _address, int _Port)
            {
    
                TcpListener _TcpListener = new TcpListener(IPAddress.Any, _Port);
                _TcpListener.Start();
                int i = 0;
                while (true)
                {
                    i++;
                    TcpClient _LocalSocket = _TcpListener.AcceptTcpClient();
                    NetworkStream _NetworkStreamLocal = _LocalSocket.GetStream();
    
                    TcpClient _RemoteSocket = new TcpClient(_address, _Port);
                    NetworkStream _NetworkStreamRemote = _RemoteSocket.GetStream();
                    Console.WriteLine("\n<<<<<<<<<connected>>>>>>>>>>>>>");
                    Client _RemoteClient = new Client("remote" + i)
                    {
                        _SendingNetworkStream = _NetworkStreamLocal,
                        _ListenNetworkStream = _NetworkStreamRemote,
                        _ListenSocket = _RemoteSocket
                    };
                    Client _LocalClient = new Client("local" + i)
                    {
                        _SendingNetworkStream = _NetworkStreamRemote,
                        _ListenNetworkStream = _NetworkStreamLocal,
                        _ListenSocket = _LocalSocket
                    };
                }
            }
            public class Client
            {
                public TcpClient _ListenSocket;
                public NetworkStream _SendingNetworkStream;
                public NetworkStream _ListenNetworkStream;
                Thread _Thread;
                public Client(string Name)
                {
                    _Thread = new Thread(new ThreadStart(ThreadStartHander));
                    _Thread.Name = Name;
                    _Thread.Start();
                }
                public void ThreadStartHander()
                {
                    Byte[] data = new byte[99999];
                    while (true)
                    {
                        if (_ListenSocket.Available > 0)
                        {
                            int _bytesReaded = _ListenNetworkStream.Read(data, 0, _ListenSocket.Available);
                            _SendingNetworkStream.Write(data, 0, _bytesReaded);
                            Console.WriteLine("(((((((" + _bytesReaded + "))))))))))" + _Thread.Name + "\n" + ASCIIEncoding.ASCII.GetString(data, 0, _bytesReaded).Replace((char)7, '?'));
                        }
                        Thread.Sleep(10);
                    }
                }
    
            }
        }
    }
    

    VB.NET Code Below

    Imports System.Collections.Generic
    Imports System.Linq
    Imports System.Text
    Imports System.Net.Sockets
    Imports System.Diagnostics
    Imports System.Net
    Imports System.Threading
    
    Namespace ConsoleApplication1
        Class Program
            Private Shared Sub Main(args As String())
                Dim Address As String = "*PUT IP ADDRESS HERE WHERE UDP SERVER IS*"
                Dim UDPPort As Integer = *PUT UDP SERVER PORT HERE*
                Dim _UdpRedirect As New UdpRedirect() With { _
                    Key ._address = Address, _
                    Key ._Port = UDPPort _
                }
                Dim _Thread As New Thread(AddressOf _UdpRedirect.Connect)
                _Thread.Name = "UDP"
                _Thread.Start()
    
                Dim TCPPort As Integer = *PUT TCP SERVER PORT HERE*
                Dim _TcpRedirect As New TcpRedirect(Address, TCPPort)
            End Sub
        End Class
        Class UdpRedirect
            Public _address As String
            Public _Port As Integer
            Public Sub New()
            End Sub
    
            Public Sub Connect()
                Dim _UdpClient As New UdpClient(_Port)
                Dim LocalPort As System.Nullable(Of Integer) = Nothing
                While True
                    Dim _IPEndPoint As IPEndPoint = Nothing
                    Dim _bytes As Byte() = _UdpClient.Receive(_IPEndPoint)
                    If LocalPort Is Nothing Then
                        LocalPort = _IPEndPoint.Port
                    End If
                    Dim Local As Boolean = IPAddress.IsLoopback(_IPEndPoint.Address)
                    Dim AddressToSend As String = Nothing
                    Dim PortToSend As Integer = 0
                    If Local Then
                        AddressToSend = _address
                        PortToSend = _Port
                    Else
                        AddressToSend = "127.0.0.1"
                        PortToSend = LocalPort.Value
                    End If
                    _UdpClient.Send(_bytes, _bytes.Length, AddressToSend, PortToSend)
                End While
            End Sub
        End Class
        Class TcpRedirect
            Public Sub New(_address As String, _Port As Integer)
    
                Dim _TcpListener As New TcpListener(IPAddress.Any, _Port)
                _TcpListener.Start()
                Dim i As Integer = 0
                While True
                    i += 1
                    Dim _LocalSocket As TcpClient = _TcpListener.AcceptTcpClient()
                    Dim _NetworkStreamLocal As NetworkStream = _LocalSocket.GetStream()
    
                    Dim _RemoteSocket As New TcpClient(_address, _Port)
                    Dim _NetworkStreamRemote As NetworkStream = _RemoteSocket.GetStream()
                    Console.WriteLine(vbLf & "<<<<<<<<<connected>>>>>>>>>>>>>")
                    Dim _RemoteClient As New Client("remote" + i) With { _
                        Key ._SendingNetworkStream = _NetworkStreamLocal, _
                        Key ._ListenNetworkStream = _NetworkStreamRemote, _
                        Key ._ListenSocket = _RemoteSocket _
                    }
                    Dim _LocalClient As New Client("local" + i) With { _
                        Key ._SendingNetworkStream = _NetworkStreamRemote, _
                        Key ._ListenNetworkStream = _NetworkStreamLocal, _
                        Key ._ListenSocket = _LocalSocket _
                    }
                End While
            End Sub
            Public Class Client
                Public _ListenSocket As TcpClient
                Public _SendingNetworkStream As NetworkStream
                Public _ListenNetworkStream As NetworkStream
                Private _Thread As Thread
                Public Sub New(Name As String)
                    _Thread = New Thread(New ThreadStart(AddressOf ThreadStartHander))
                    _Thread.Name = Name
                    _Thread.Start()
                End Sub
                Public Sub ThreadStartHander()
                    Dim data As [Byte]() = New Byte(99998) {}
                    While True
                        If _ListenSocket.Available > 0 Then
                            Dim _bytesReaded As Integer = _ListenNetworkStream.Read(data, 0, _ListenSocket.Available)
                            _SendingNetworkStream.Write(data, 0, _bytesReaded)
                            Console.WriteLine("(((((((" + _bytesReaded + "))))))))))" + _Thread.Name + vbLf + ASCIIEncoding.ASCII.GetString(data, 0, _bytesReaded).Replace(CChar(7), "?"C))
                        End If
                        Thread.Sleep(10)
                    End While
                End Sub
    
            End Class
        End Class
    End Namespace
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this warning in my error logs and wanted to know how to
I get this error: System.Reflection.TargetException: Object does not match target type. when trying to
I know this issue has been addressed before but I have not found an
I get this error: Can't locate Foo.pm in @INC Is there an easier way
I get this error on an update panel within a popupControlExtender which is within
I get this error when I do an svn update : Working copy XXXXXXXX
I get this error:- You have an error in your SQL syntax; check the
We get this error in Visual Studio 2005 and TFS very often. Can anyone
i get this error {Method 'System.DateTime ConvertTimeFromUtc(System.DateTime, System.TimeZoneInfo)' has no supported translation to SQL.}
I get this error message when installing SQL 2005 Analysis services. The cabinet File

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.