我需要的只是一个简单的TCPClient/Listener(“hello world”)示例。我是个新手,微软的TCPClient/Listener类示例不是我要找的。我只想让TCPClient发送一条消息“Hello world”,然后TCPListener接收到该消息并回复一条消息“我已经收到了你的Hello world消息”,请问有什么简单的方法实现吗?
如果能提供一点帮助就太好了。我现在只有让TCPClient发送“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)