scketfuncs.h 594 B

1234567891011121314151617181920212223
  1. #pragma once
  2. #include <string>
  3. #include <sys/socket.h> // Linux socket头文件
  4. #include <netinet/in.h> // 网络地址结构
  5. #include <netinet/tcp.h> // TCP协议选项
  6. #include <arpa/inet.h> // IP地址转换
  7. #include <unistd.h> // close函数
  8. #include <fcntl.h> // 文件控制选项
  9. #include <errno.h> // 错误号
  10. #include <cstring> // 字符串操作
  11. #include <string> // string类
  12. using namespace std;
  13. // 将错误代码转换为可读字符串
  14. string FormatLinkError(int ErrorCode);
  15. // 安全关闭套接字
  16. int CLOSESOCKET(int& s);
  17. // 设置TCP keep-alive选项
  18. int socket_set_keepalive(int fd);