望远镜系统监控+软件升级
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

47 lines
1.2 KiB

  1. #include"../tcpSocket/tcpSocket.h"
  2. #include"../tcpSocket/fileOperation.h"
  3. //ctrl+k+c
  4. int main()
  5. {
  6. init_Socket();
  7. SOCKET serfd = create_serverSocket(); //创建服务器socket
  8. printf("server has created successfully,waiting for client connect..\n");
  9. //等待客户端连接
  10. SOCKET clifd = accept(serfd,NULL,NULL); //创建用于连接的客户端socket
  11. if (clifd == INVALID_SOCKET) //失败情况
  12. {
  13. err("accept");
  14. }
  15. printf("客户端发起与服务器的连接,成功...\n");
  16. //可以与客户端进行通信
  17. struct MsgHeader msg = { .msgID = MSG_SEND,.fileInfo.fileName = "./AutoHotkey_setup.exe" };
  18. sendFile(clifd, (char*)&msg); //发送的文件名
  19. //if (SOCKET_ERROR == send(clifd, "服务器向客户端发来的消息", 24, 0)) // 字符个数,中文1个汉字=2个字符
  20. //{
  21. // err("dingyaya send");
  22. //}
  23. //char recvBuf[1024] = ""; //定义缓冲区2^10
  24. //int ret = recv(clifd, recvBuf, 1024, 0); //接收客户端发来的
  25. //if (ret == 0)
  26. //{
  27. // printf("客户端正常下线...\n"); //返回值ret=0客户端正常下线
  28. //}
  29. //else if (ret < 0)
  30. //{
  31. // err("recv");
  32. //}
  33. //puts(recvBuf); //在客户端上显示服务器发送的消息
  34. closesocket(clifd); //系统函数,关闭客户端
  35. closesocket(serfd);
  36. close_Socket();
  37. getchar(); //防止闪退
  38. return 0;
  39. }