我正在尋找的是一個簡單的TCPClient/Listner(「hello world」)示例。我是新手,Microsoft TCPClient/Listner類的例子並不是我正在尋找的。我正在尋找的是TCPClient發送一條消息「Hello world」,並讓TCPListener獲取消息併發回消息「我收到了你的hello world消息」?簡單的TCPClient/Listner(「hello world」)示例
有一點幫助會很大。我所有的是TCPClient發出「Hello World」。這會工作嗎?
Dim port As Int32 = 13000
Dim client As New TcpClient("192.168.0.XXX", port)
' Translate the passed message into ASCII and store it as a Byte array.
Dim data As [Byte]() = System.Text.Encoding.ASCII.GetBytes("Hello World")
' Get a client stream for reading and writing.
' Stream stream = client.GetStream();
Dim stream As NetworkStream = client.GetStream()
' Send the message to the connected TcpServer.
stream.Write(data, 0, data.Length)
Yes..that應該罰款發送;假設沒有實際的協議(大多數情況下)。然而,接收比人們想象的要複雜得多。您可能對我的[文章]感興趣(http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/A_11178-A-Peer-To-Peer-LAN-Chat-Application-in -Visual-Basic-Net-using-TcpClient-and-TcpListener.html)。 –
該鏈接真的幫助!謝謝!! –