寻找可用于测试套接字应用程序的简单套接字服务器应用程序?
Looking for simple socket server application that could be used to test socket applications?
我正在使用调制解调器开发嵌入式系统,我想从调制解调器连接到任何可以显示来自客户端的数据并可选择向客户端发送一些数据的设备。
我正在寻找一种工具:
- 打开 TCP 套接字
- 客户端连接时打印一些信息
- 打印传入数据
- 向客户端发送一些数据,也许从控制台输入? (可选)
- 客户端断开连接时打印一些信息
我可以拿这个(或另一个套接字示例)并编译它:
https://www.geeksforgeeks.org/tcp-server-client-implementation-in-c/
但也许 Debian APT 存储库中有类似的东西或更好的东西?
对于简单的 TCP 服务器,您可以使用 netcat
:
Ncat is a feature-packed networking utility which reads and writes data across networks from the command line. Ncat was written for the Nmap Project and is the culmination of the currently splintered family of Netcat incarnations. It is designed to be a reliable back-end tool to instantly provide network connectivity to other applications and users. Ncat will not only work with IPv4 and IPv6 but provides the user with a virtually limitless number of potential uses.
它可以通过TCP/UDP提供双向通信。甚至还有一些仅使用 netcat 的 HTTP 服务器实现。
就这么简单:
$ nc -l 0.0.0.0 9999
瞧,您现在正在所有接口中侦听端口 9999,并且可以从您的设备进行连接。
要测试通信,您也可以使用 netcat
。在另一个 bash 会话中,试试这个:
$ nc 127.0.0.1 9999
在所有发行版上都简单易用:)
我正在使用调制解调器开发嵌入式系统,我想从调制解调器连接到任何可以显示来自客户端的数据并可选择向客户端发送一些数据的设备。
我正在寻找一种工具:
- 打开 TCP 套接字
- 客户端连接时打印一些信息
- 打印传入数据
- 向客户端发送一些数据,也许从控制台输入? (可选)
- 客户端断开连接时打印一些信息
我可以拿这个(或另一个套接字示例)并编译它:
https://www.geeksforgeeks.org/tcp-server-client-implementation-in-c/
但也许 Debian APT 存储库中有类似的东西或更好的东西?
对于简单的 TCP 服务器,您可以使用 netcat
:
Ncat is a feature-packed networking utility which reads and writes data across networks from the command line. Ncat was written for the Nmap Project and is the culmination of the currently splintered family of Netcat incarnations. It is designed to be a reliable back-end tool to instantly provide network connectivity to other applications and users. Ncat will not only work with IPv4 and IPv6 but provides the user with a virtually limitless number of potential uses.
它可以通过TCP/UDP提供双向通信。甚至还有一些仅使用 netcat 的 HTTP 服务器实现。
就这么简单:
$ nc -l 0.0.0.0 9999
瞧,您现在正在所有接口中侦听端口 9999,并且可以从您的设备进行连接。
要测试通信,您也可以使用 netcat
。在另一个 bash 会话中,试试这个:
$ nc 127.0.0.1 9999
在所有发行版上都简单易用:)