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)
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
VB.NET Code Below