求screenspydlg.cpp源码的注释,越详细越好,谢谢! 50
1个回答
2016-04-23
展开全部
最简单的那种?我给你写一个=,=//服务器#include#include#include#include#include#include#include#include#include#include#include#includemain(){//创建套接字intserverSocket=socket(AF_INET,SOCK_STREAM,0);structsockaddr_inserver_addr;structsockaddr_inclientAddr;intaddr_len=sizeof(clientAddr);intclient;charbuffer[200];//创建地址bzero(&server_addr,sizeof(server_addr));server_addr.sin_family=AF_INET;server_addr.sin_port=htons(5555);server_addr.sin_addr.s_addr=htonl(INADDR_ANY);//绑定bind(serverSocket,(structsockaddr*)&server_addr,sizeof(server_addr));//帧听listen(serverSocket,5);printf("客户端发过来的:\n");//接收client=accept(serverSocket,(sockaddr*)&clientAddr,(socklen_t*)&addr_len);printf("客户端发过来的:\n");while(1){if(recv(client,buffer,sizeof(buffer),0)>0)printf("客户端发过来的:%s\n",buffer);}return0;}//客户端#include#include#include#include#include#include#include#include#include#include#include#includemain(){structsockaddr_inserverAddr;intclientSocket=socket(AF_INET,SOCK_STREAM,0);charsendbuf[200];//创建地址信息serverAddr.sin_family=AF_INET;serverAddr.sin_port=htons(5555);serverAddr.sin_addr.s_addr=inet_addr("127.0.0.1");//连接服务器connect(clientSocket,(sockaddr*)&serverAddr,sizeof(serverAddr));printf("连接目标主机中..\n连接完成\n");//while(1){printf("请输入发给服务器的数据:");scanf("%s",sendbuf);//strcmp函数作用,比较两个东东(按ASCII值大小相比较),相同就==0。if(strcmp(sendbuf,"x")==0)break;send(clientSocket,sendbuf,sizeof(sendbuf),0);}close(clientSocket);return0;}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询