在開發過程中,我們通常使用localhost作爲主機名,像下面如何指定的IP地址的TcpClient使用
Dim serverListener As New TcpClient("localhost", 8585)
我希望用戶通過文本框可以輸入自己的IP地址,而不是,就像
Dim serverListener As New TcpClient(textbox1.text, 8585)
但是,這不適合我。有任何想法嗎?謝謝!
在開發過程中,我們通常使用localhost作爲主機名,像下面如何指定的IP地址的TcpClient使用
Dim serverListener As New TcpClient("localhost", 8585)
我希望用戶通過文本框可以輸入自己的IP地址,而不是,就像
Dim serverListener As New TcpClient(textbox1.text, 8585)
但是,這不適合我。有任何想法嗎?謝謝!
也許this會有幫助嗎?
您還可以使用IPAdress.TryParse()檢查其有效ADRESS
的TcpClient
constructor that accepts a string
and an int
參數的形式預期的主機名和端口,而不是IP地址。
您可能想要使用TcpClient
constructor that takes an IPEndPoint
參數instread。有關IPEndPoint
class on MSDN的更多信息,但簡而言之,它代表IP地址和端口號。