vb.net - 简单的 TCPClient/Listener ("hello world") 示例

标签 vb.net client-server tcpclient tcplistener

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

相关文章:

c# - 如何创建一个组件,使 VBA 能够访问我自己正在运行的应用程序?

android - 使用 WiFI 从笔记本电脑通过 Web 浏览器管理 Android 设备

c# - 套接字写入中多线程危险吗?

java - Java Socket shutdownOutput 和 shutdownInput 是否负责 "Duplicate ACK #: 1"

.net - DataGridView 过滤器忽略单元格、单词上的变音符号(重音)

c# - 哪个占用更多内存,字符串值还是长值?

sql - 对多个事务使用一个 SQL 连接

java - 客户端服务器应用程序java

java - 无法向所有客户端发送消息

c - 为什么 perror 函数会返回成功值?