windows c语言 网络

时间:2021-09-25 09:15:49

WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD(2, 2);

err = WSAStartup(wVersionRequested, &wsaData);
if (err != 0) {
/* Tell the user that we couldn't find a usable */
/* WinSock DLL. */
return FALSE;
}

/* Confirm that the WinSock DLL supports 2.0.*/
/* Note that if the DLL supports versions greater */
/* than 2.0 in addition to 2.0, it will still return */
/* 2.0 in wVersion since that is the version we */

/* requested. */

if (LOBYTE(wsaData.wVersion) != 2 ||
HIBYTE(wsaData.wVersion) != 2) {
/* Tell the user that we couldn't find a usable */
/* WinSock DLL. */
WSACleanup();
return FALSE;
}

fp = fopen("E:\\工作\\10_hz\\serv\\Release\\aaa.txt","r");打开文件用绝对路径或在..的worksapce的目录才可以fp = fopen("aaa.txt","r");