时间:2023-06-02 16:16:41 来源: 人气:
Linux下基于socket多线程并发通信的实现, ,编译服务器端程序 pthread_server.c :,$gcc pthread_server.c –o server –lpthread,编译客户端程序 pthread_client.c:,$gcc pthread_client.c –o client,编译在开发板上跑的客户端程序:,$arm-linux-gcc client.c –o arm_client, ,先启动服务器端的程序 server:,$./server,打开另一个终端,启动客户端的程序 client:,$./client 127.0.0.1 9734, ,把 arm_client 放到开发板上,启动 arm_client:,$./arm_client 219.222.170.9 9734, ,结果 :,服务器端:,tongs@tongs-desktop:~/c_c++_program/sock_inet_comm2$ ./server,server waiting for connect,receive from client is client,receive from client is client,receive from client is arm_client,receive from client is arm_client,客户端:,tongs@tongs-desktop:~/c_c++_program/sock_inet_comm2$ ./client 127.0.0.1 9734,client,client,exit, ,开发板服务器端,[/mnt/yaffs/nfs_share/sock_tcp/thread_socket]./arm_client 219.222.170.9 9734,arm_client,arm_client,exit,