任何语言端口侦听器?[UDP]



我正在寻找任何一种可以查看UDP连接的端口侦听器。原因是我正试图写一个程序,看看人们在游戏中聊天的内容,并做出相应的回应。[并有望创建一个用于举办锦标赛的服务器自动化]

我尝试过VB.NET解决方案,但它会关闭连接,尽管花了几个小时试图让它并行连接。

进口System.Net导入System.Net.Sockets公开课表格1公用子窗体1_Load()处理Me.Load'做'将iReceivingPort标注为Integer=58690'创建一个用于读取传入数据的UdpClient。'Dim inEndPoint=新IPEndPoint(IPAddress.Passe("192.168.1.100"),iReceivingPort)'Dim endPoint=New IPEndPoint(IPAddress.Passe("192.168.1.100"),iReceivingPort)'System.Net.IPAddress.Passes("0.0.0.0"),iReceivingPort'Dim ReceivingClient=新建System.Net.Sockets.UdpClient()'ReceivingClient.ExclusiveAddressUse=False'接收Client.Client.SocketOption(SocketOptionLevel.Socket,SocketOptionName.ReuseAddress,True)'接收Client.Client.Bind(inEndPoint)Dim ip=ip地址。解析("192.168.1.100")Dim端口=65267Dim socket=新套接字(AddressFamily.InterNetwork,SocketType.Dgram,ProtocolType.Udp)插座设置套接字选项(SocketOptionLevel.Socket,SocketOptionName.ReuseAddress,True)插座绑定(新IPEndPoint(ip,端口))'创建一个IPEndPoint来记录发件人的IP地址和端口号。IPEndPoint将允许您读取从任何来源发送的数据报。'Dim RemoteIpEndPoint As New System.Net.IEndpoint(System.Net.IPAddress.Passe("0.0.0.0"),iReceivingPort)尝试'阻止,直到远程主机在此套接字上返回消息为止。Dim缓冲区Dim receiveBytes As[Byte]()=套接字。接收(缓冲区)Dim returnData As String=System.Text.Encoding.ASCII.GetString(receiveBytes)Console.WriteLine(("这是您收到的消息"+returnData.ToString())'Console.WriteLine(("此消息是从"+inEndPoint.Address.ToString()+"发送的,位于其端口号"+inEndPoint.port.ToString()))捕获e作为异常Console.WriteLine(e.ToString())结束尝试'System.Threading.Thread.Sleep(1000)'接收Client.Close()'循环结束子'MyUdpClientCommunicator'结束类

找到了一个解决方案,如果有人想要的话:[巨蟒]

import socket, struct
# the public network interface
HOST = socket.gethostbyname(socket.gethostname())
# create a raw socket and bind it to the public interface
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP)
s.bind(("192.168.1.100", 63578))
while 1:
    # Include IP headers
    s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
    # receive all packages
    s.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
    # receive a package
    packet, address = s.recvfrom(65565)
    print(packet)
    # disabled promiscuous mode
    s.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)

代码不完整,但这正是我需要的atm。

您可能想要签出nMaphttp://nmap.org/book/nping-man-udp-mode.html

尝试学习rubyhttps://www.ruby-lang.org/en/然后使用socketgem来处理套接字。这很容易学。