When you make command-line programming using visual studio rather then using automated MFC classes, you may encounter socket error that always returns -1 on "socket()" function call.
Following codes are required on intiali functions such as "main()"
int nErrorStatus;
WORD wVersionRequested = MAKEWORD(2, 2);
WSADATA wsaData;
WORD wVersionRequested = MAKEWORD(2, 2);
WSADATA wsaData;
nErrorStatus = WSAStartup(wVersionRequested, &wsaData);
if(nErrorStatus!=0)
{
printf("WSAStartup failed\n");
}
if(nErrorStatus!=0)
{
printf("WSAStartup failed\n");
}
Also, when you make it clear, you can use following code.
WSACleanup();
댓글 없음:
댓글 쓰기