Network programming (two-person chat)

我们可以做一个服务器,让客户端接入就可**双方交互数据,可以相互聊天**了。

First of all, the server:
create a server, once a client connection comes in, we create a child process to continuously receive data, one is to continuously send data.
Server code:
Insert picture description here
Insert picture description here
Insert picture description here

Client code:
Insert picture description here
Insert picture description here

Run the server first, connect the client to the connection, and then send data to each other.
Server running process:
Insert picture description here
client running process:
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_47457689/article/details/108468891