Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我有这种 IP 地址192.168.110.128,获取所需八位字节的方法已经在这里得到解答,但它不适用于包含这样的端口号的 IP 192.168.110.128:60423。
192.168.110.128
192.168.110.128:60423
您无法将其解析为 IPAddress 对象,因为端口不是 IP 地址的一部分。它属于 TCP/UDP。
相反,您必须将其解析为 URI,然后获取其主机值,将其解析为 IPAddress,然后就可以了:
Dim address As String = "192.168.110.128:60423" Dim ip = IPAddress.Parse(New Uri("http://" & address).Host) Debug.WriteLine(ip.GetAddressBytes(3))