如何将IP地址转换为IP HostEntry在VB.NET?(How to convert IP A

2019-10-29 09:19发布

我建立一个小的应用程序,你将它输入一个掩码文本框后,将改变你的IP地址。 我真的很接近想出来的,但我需要与H = myNewIP部分帮助,因为我无法从IP地址到IP主机条目转换:

Public Class MainForm
Dim h As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName)
Dim myNewIP As System.Net.IPAddress
Dim myIPEndPoint As System.Net.IPEndPoint
Dim strLocalIp As String

Private Sub
        myNewIP = System.Net.IPAddress.Parse(TextBox1.Text)
        myIPEndPoint = New System.Net.IPEndPoint(myNewIP, 0)
        h = myNewIP
        ipTextBox.Text = myNewIP.ToString
End Sub

Answer 1:

IPEndPoint endpoint = new IPEndPoint(System.Net.IPAddress.Parse("your ip"), 1111);

关于这行只是一个忠告:

Dim h As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName)
Dim myNewIP As System.Net.IPAddress
Dim myIPEndPoint As System.Net.IPEndPoint
Dim strLocalIp As String

如果他们在一个方法只使用本地申报。



文章来源: How to convert IP Address to IP HostEntry in VB.NET?