Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sockets 错误C2678:二进制'==';:未找到接受类型为';的左操作数的运算符;标准:活页夹<;标准::_非受迫、插座和;,SOCKADDR*,无符号整数>';_Sockets_Visual C++_Operators - Fatal编程技术网

Sockets 错误C2678:二进制'==';:未找到接受类型为';的左操作数的运算符;标准:活页夹<;标准::_非受迫、插座和;,SOCKADDR*,无符号整数>';

Sockets 错误C2678:二进制'==';:未找到接受类型为';的左操作数的运算符;标准:活页夹<;标准::_非受迫、插座和;,SOCKADDR*,无符号整数>';,sockets,visual-c++,operators,Sockets,Visual C++,Operators,在这个函数中,我看到了这个错误 错误C2678:二进制“==”:未找到接受“std::\u Binder”类型左侧操作数的运算符(或没有可接受的转换) 有人能帮我吗? 谢谢。正如Igor解释的那样:“尝试::bind而不是普通的bind。编译器认为您是从标准库调用std::bind,而不是从Winsock API调用bind。” 它对我起作用了。试试::用bind代替普通的bind。摆脱使用名称空间std的习惯。编译器认为您是从标准库调用std::bind,而不是从Winsock API调用bi

在这个函数中,我看到了这个错误 错误C2678:二进制“==”:未找到接受“std::\u Binder”类型左侧操作数的运算符(或没有可接受的转换)

有人能帮我吗? 谢谢。

正如Igor解释的那样:“尝试::bind而不是普通的bind。编译器认为您是从标准库调用std::bind,而不是从Winsock API调用bind。”


它对我起作用了。

试试
::用bind
代替普通的
bind
。摆脱
使用名称空间std的习惯。编译器认为您是从标准库调用
std::bind
,而不是从Winsock API调用
bind
(前者在重载解析方面更匹配,因为后者在最后一个参数中有符号/无符号不匹配)。@IgorTandetnik这应该作为答案发布。
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");
}