本人在做一程序设计时,遇到以下麻烦:
在调用WSAStartup(WORD wVersionRequested,&WSAData)时,它说那WSAData非法表示,但我不知道如何改,如果你知道的话,请回答好吗?
还有,在用到recv(SOCKET s,char FAR *buf,int len,int flags),我在这里的flags是用NOT_FLAG_SET写,但它说我没有定义,我想问一问,我是不是要把flags写成0???
在调用WSAStartup(WORD wVersionRequested,&WSAData)时,它说那WSAData非法表示,但我不知道如何改,如果你知道的话,请回答好吗?
还有,在用到recv(SOCKET s,char FAR *buf,int len,int flags),我在这里的flags是用NOT_FLAG_SET写,但它说我没有定义,我想问一问,我是不是要把flags写成0???
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 2, 2 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
return;
}
/* Confirm that the WinSock DLL supports 2.2.*/
/* Note that if the DLL supports versions greater */
/* than 2.2 in addition to 2.2, it will still return */
/* 2.2 in wVersion since that is the version we */
/* requested. */
if ( LOBYTE( wsaData.wVersion ) != 2 ||
HIBYTE( wsaData.wVersion ) != 2 ) {
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
WSACleanup( );
return;
}
Library: Use Ws2_32.lib.
WSAData data;flags你用0好了