在这种情况下使用哪个端口? [英] Which port to use for this situation?
问题描述
人们
我知道我之前发过类似的东西,但这是一个完全不同的问题。
问题是,使用以下代码,端口54545不起作用。该代码旨在通过端口变量将消息发送到IP地址。
我希望代码能够,例如,向您发送消息,读取此消息,如果您有接收器程序(必须在世界上任何地方,只要你有网络连接)
Hi people
I know i''ve posted something similar to this before, but it''s a completely different question.
The problem is, that with the following code, port 54545 does not work. The code is intended to send a message via the port variable to the IP address.
I want the code to be able to, for example, send a message to you, the one reading this, if you have the receiver program (which has to be anywhere in the world, providing you have a network connection)
Imports System.Net
Imports System.Net.Sockets
Imports System.Threading
Imports System.Text
Public Class Form1
Private Const port As Integer = 54545
Dim RecipientIPAddress As String = Nothing '255.255.255.255 for local network
Private sendingClient As UdpClient
Private Sub SendMsgButton_Click() Handles SendMsgButton.Click
RecipientIPAddress = IPToSendToTextbox.text 'for example, 192.168.1.99
InitializeSender()
End Sub
Private Sub InitializeSender()
sendingClient = New UdpClient(RecipientIPAddress, port)
sendingClient.EnableBroadcast = True
End Sub
Public toSend As String
Dim data() As Byte
Public Shared Sub go()
form1.data = Encoding.ASCII.GetBytes(form1.toSend)
form1.sendingClient.Send(form1.data, form1.data.Length)
End Sub
end class
我对这个问题了解的事情:
* UDPClient端口范围从5454 [2-5]
*端口80无法工作
有没有人知道一个适用于此的端口号?
谢谢。
Things I know about the problem:
* UDPClient Ports range from 5454[2-5]
* Port 80 doesn''t work
Does anyone know a port number that will work for this?
Thanks.
推荐答案
任何未使用的端口号都可以使用,您的问题可能是阻止流量的防火墙。
Any port number not in use should work, your problem might be a firewall blocking the traffic.
这篇关于在这种情况下使用哪个端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!