0

Seem to be having a bit of an issue here, and this is probably a really dumb question:

#incude <thread>

and

#include <winsock2.h>

both contain a function called bind(). I want to call this winsock2 bind:

bind(listenerSocket._internalCustomSocket, (sockaddr*)&listenerSocket._peer, listenerSocket._peerLength)

Where listenerSocket is my custom socket class that looks like this:

class CustomSocket
{
public:
    CustomSocket(int port);
    ~CustomSocket();

    SOCKET OpenSocket(Listener* host);

    int _port;
    SOCKET _internalCustomSocket;
    sockaddr_in _peer;
    int _peerLength;

};

However, it instead defaults to using the bind() which looks like

_NODISCARD inline _Binder<_Unforced, _Fx, _Types...> bind(_Fx&& _Func, _Types&&... _Args)

How do I specify which one it is that I want to call?

The only solution I've found so far is to not include the include

1 Answers1

0

First of all, eliminate any use of using namespace std; from your code. That will just mess things up.

Then, to access Winsock's bind, you can write:

::bind (...);

And to access the version of bind in the STL, you can write:

std::bind (...);

And now you know what namespaces are for.

Paul Sanders
  • 24,133
  • 4
  • 26
  • 48