1:编译环境,安装合适的mingw编译链
apt-cache search mingw
apt-get install gcc-mingw-w64-x86-64
2:linux和windows的一些接口区别:
https://blog.youkuaiyun.com/zhangbohh8662/article/details/62044538
3:头文件:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <math.h>
#include <wchar.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdio.h>
#include <stdlib.h>
#pragma comment(lib,"ws2_32.lib")
4:mingw32编程时fwrite写文件时自动多了0X0D
https://blog.youkuaiyun.com/shen_001/article/details/8750748
5:write发送socket数据时,发不出去,得使用send
6:fopen文件时,文件中不能包含特殊字符,否则fopen失败,如: > / \ | : " * ?
6:编译指令:
x86_64-w64-mingw32-gcc -o tcp_client.o -g tcp_client.c
x86_64-w64-mingw32-gcc tcp_client.c -lws2_32 -lpthread -lm