简单 TCP 会话/侦听器 ( "hello world" ) 示例



我正在寻找的只是一个简单的TCPClient/Listener("hello world"(示例。我是新手,Microsoft TCPClient/Listener 类示例不是我想要的。我正在寻找的只是TCPClient发送消息"Hello world",TCPListener获取消息并发送消息"我收到了你的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)

这两个教程应该向您展示如何以最低限度做到这一点。我认为第一个更针对你想要的东西。

试试这个: http://www.nullskull.com/articles/20020323.asp

或者这个:http://www.codeproject.com/Articles/38914/A-TCP-IP-Chat-Program

相关内容

最新更新