我正在寻找的只是一个简单的 TCPClient/Listener(“hello world”)示例。我是新手,Microsoft TCPClient/Listener 类示例不是我想要的。我正在寻找的是 TCPClient 发送消息“Hello world”和 TCPListener 获取消息并发送回消息“我收到你的 hello world 消息”?
一点帮助会很棒。我所拥有的只是发送“Hello World”的 TCPClient。这行得通吗?
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)
最佳答案
这两个教程应该向您展示如何以最低限度的方式做到这一点。第一个更针对你想要的我认为。
试试这个:http://www.nullskull.com/articles/20020323.asp
或者这个:http://www.codeproject.com/Articles/38914/A-TCP-IP-Chat-Program
关于vb.net - 简单的 TCPClient/Listener ("hello world") 示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19232410/