TCP套接字简单通信 本篇gitee 学习完udp套接字通信后,再来看TCP套接字。 四个文件tcp_server.hpp, tcp_server.cc,tcp_client.cc,makefile。 makefile .PHONY: all all:tcp_client tcp_server tcp_client:tcp_client.cc g++ -o $@ $^ -std=c++11 -lpthread tcp_server:tcp_server.cc g++ -o $@ $^ -std=c++11 -lpthread .PHONY: clean clean: rm -f tcp_client tcp_server 1、基本框架 和udp的有些一样。我们有些序列需要主机转网络,但发送的消息不需要,是因为操作系统会自动转大小端,处理交互用的消息。 tcp_server.hpp namespace ns_server { static const uint16_t defaultport = 8081; class TcpServer { public:...
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Get in touch with char
Contact char, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack