UDP PROXY / PIPE,请求的地址在其上下文中无效
我收到此错误..并且我知道 IP 地址无效!但它是一个服务器,它应该仅基于端口。
错误=
runProxy 错误 @ 请求的地址在其上下文中无效 0.0.0.0:7900
有人可以告诉我我做错了什么吗?
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
PS>我的客户端连接到 127.0.0.1 : 7900
..
我希望它将连接重新路由到 txtIP.text : 7900
(txtListeningPort.Text< /代码>)
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
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个工作
TCP 或 UDP 重定向器 / UDP 代理 / UDP 管道 / TCP 代理 / TCP 管道
我创建了许多不同模型的 UDP 代理连接保镖,它们似乎都使用标准 Sockets 类失去了连接,但使用 UDPClient 类这个问题完全消失了。
UDP 代理只有 25 行代码,但功能和稳定性却非常出色
下面是如何在 TCP 和 UDP 中执行此操作的示例
C# 下面的代码
VB.NET下面的代码
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