【问题标题】:Simple TCPClient/Listener ("hello world") example简单的 TCPClient/Listener(“hello world”)示例
【发布时间】:2013-10-14 11:21:39
【问题描述】:

我正在寻找的只是一个简单的 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)

【问题讨论】:

  • 是的..发送应该没问题;假设没有实际的协议(大部分时间都有)。然而,接收总是比人们想象的要复杂。你可能对我在 EE 的article 感兴趣。
  • 那个链接真的很有帮助!!谢谢!!

标签: vb.net client-server tcpclient tcplistener


【解决方案1】:

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

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

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

【讨论】:

  • 请添加一些代码,如果您共享的那些网站被弃用,那么您的答案也将被弃用。
猜你喜欢
  • 1970-01-01
  • 2017-08-04
  • 1970-01-01
  • 2020-03-08
  • 1970-01-01
  • 1970-01-01
  • 2013-03-10
  • 2012-07-03
  • 1970-01-01
相关资源
最近更新 更多