1.实现Linux与Windows的共同函数
a.linux平台头文件引用:
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
b.windows平台头文件引用
#include <Ws2tcpip.h>
#include <windows.h>
c.windows平台在创建socket前要加载WSA库,在关闭socket后要释放WSA库,linux平台不用 ,所以为了代码兼容,需要对同一功能不现平台的差异实现
windows:
通过WSAStartup加载WSA库
#define _sock_init( ) { WSADATA wsaData; WSAStartup( MAKEWO