Reputation: 562
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.
Upvotes: 0
Views: 127
Reputation: 5732
You're trying to call a class member connect. Prefix the connect with :: so it finds the correct function.
if (::connect(sockfd[0], &sock.addr, sizeof(sock.inaddr)) == SOCKET_ERROR){
Upvotes: 3
Reputation: 881243
It looks like your class has its own connect
method, try calling ::connect
instead, which should give you the 'standard' one.
Upvotes: 0