hassan dusti
hassan dusti

Reputation: 19

error C2678: binary '==': no operator found which takes a left-hand operand of type 'std::_Binder<std::_Unforced,SOCKET &,SOCKADDR *,unsigned int>'

in this function I see this error error C2678: binary '==': no operator found which takes a left-hand operand of type 'std::_Binder' (or there is no acceptable conversion)

void WComm::startServer(int port)
{
    // Connect to a server.
    con.sin_family = AF_INET;
    con.sin_addr.s_addr = inet_addr("0.0.0.0");
    con.sin_port = htons(port);
    if (bind(m_socket, (SOCKADDR*)&con, sizeof(con)) == SOCKET_ERROR)
    {
        printf("Failed to connect.\n");
        WSACleanup();
        return;
    }

    // Listen on the socket.
    if (listen(m_socket, 1) == SOCKET_ERROR)
    printf("Error listening on socket.\n");
}

anyone cane help me? thanks.

Upvotes: 1

Views: 2907

Answers (1)

Kreshnik
Kreshnik

Reputation: 2831

As Igor was explaining "try ::bind instead of the plain bind. The compiler thinks you are calling std::bind from the Standard Library, rather then bind from Winsock API."

It worked for me.

Upvotes: 3

Related Questions