简单的TCPClient/Listener("hello world")示例

Ben*_*nes 7 vb.net client-server tcplistener tcpclient

我正在寻找的是一个简单的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)
Run Code Online (Sandbox Code Playgroud)

Syn*_*ps3 5

这两个教程应该向您展示如何以最低限度完成它.第一个更瞄准你想要的东西.

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

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

  • 请添加一些代码,如果您共享的那些网站已弃用,那么您的答案也将被弃用. (7认同)