Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 任何语言端口侦听器?[UDP]_Vb.net_Sockets - Fatal编程技术网

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

Vb.net 任何语言端口侦听器?[UDP],vb.net,sockets,Vb.net,Sockets,我正在寻找任何类型的端口侦听器,可以查看UDP连接。原因是我正试图编写一个程序,查看人们在游戏中聊天的内容,并做出相应的回应。[并希望创建一个用于举办锦标赛的服务器自动机] 我尝试了一个VB.NET解决方案,但它会关闭连接,尽管我花了几个小时试图让它并排连接 Imports System.Net Imports System.Net.Sockets Public Class Form1 Public Sub Form1_Load() Handles Me.Loa

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

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

Imports System.Net Imports System.Net.Sockets Public Class Form1 Public Sub Form1_Load() Handles Me.Load 'Do 'Dim iReceivingPort As Integer = 58690 'Creates a UdpClient for reading incoming data. 'Dim inEndPoint = New IPEndPoint(IPAddress.Parse("192.168.1.100"), iReceivingPort) 'Dim endPoint = New IPEndPoint(IPAddress.Parse("192.168.1.100"), iReceivingPort) 'System.Net.IPAddress.Parse("0.0.0.0"), iReceivingPort 'Dim ReceivingClient = New System.Net.Sockets.UdpClient() 'ReceivingClient.ExclusiveAddressUse = False 'ReceivingClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, True) 'ReceivingClient.Client.Bind(inEndPoint) Dim ip = IPAddress.Parse("192.168.1.100") Dim port = 65267 Dim socket = New Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp) socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, True) socket.Bind(New IPEndPoint(ip, port)) 'Creates an IPEndPoint to record the IP address and port number of the sender. ' The IPEndPoint will allow you to read datagrams sent from any source. 'Dim RemoteIpEndPoint As New System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), iReceivingPort) Try ' Blocks until a message returns on this socket from a remote host. Dim buffer Dim receiveBytes As [Byte]() = socket.Receive(buffer) Dim returnData As String = System.Text.Encoding.ASCII.GetString(receiveBytes) Console.WriteLine(("This is the message you received " + returnData.ToString())) 'Console.WriteLine(("This message was sent from " + inEndPoint.Address.ToString() + " on their port number " + inEndPoint.Port.ToString())) Catch e As Exception Console.WriteLine(e.ToString()) End Try ' System.Threading.Thread.Sleep(1000) ' ReceivingClient.Close() 'Loop End Sub 'MyUdpClientCommunicator End Class
代码不完整,但这正是我需要的。

您可能想查看nMap

尝试学习ruby,然后使用socket gem来处理套接字。这很容易学。

这很有用,但我可以用它制作宏/进行通信吗?不完全确定。这可能是一个起点。[.我很抱歉,我知道这些不是最有用的答案(例如,步骤1、2、3…),但它们可能会让你朝着正确的方向前进。非常感谢!;)-NVM链接已失效,我们将对此进行调查。稍后再见。:P
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)