In my network programming project (in visual C++), I am facing one problem with connect(…) api. The code segment for connect() is as below.
if (connect(sockfd[0], &sock.addr, sizeof(sock.inaddr)) == SOCKET_ERROR){
wprintf(L"connect function failed with error: %ld\n", WSAGetLastError());
closesocket(sockfd[0]);
WSACleanup();
}
for above mentioned code i am getting follwoing compilation error, which doesn’t make sense as connect should take 3 args.
error C2660: 'SampleClass::connect' : function does not take 3 arguments
Can anyone help me to figure out what i am missing here.
You’re trying to call a class member connect. Prefix the connect with :: so it finds the correct function.