简体   繁体   English

套接字绑定功能的编译错误

[英]Compilation errors with socket bind function

At the very beginning I include the following files and everything goes fine with the bind function 一开始,我包括以下文件,并且bind函数可以使一切正常

#include "stdafx.h"
#undef UNICODE

#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>

bind function 绑定功能

iResult = bind(ListenSocket, result->ai_addr, (int)result->ai_addrlen);

Things start messing up when I include the mysql libraries as well 当我也包括mysql库时,事情开始变得混乱

#include "stdafx.h"
#undef UNICODE

#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>

//mysql connections
#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>

I started debug and it give me this error 我开始调试,它给了我这个错误

IntelliSense: no suitable conversion function from "std::_Bind<false, void, SOCKET &, sockaddr *&, int>" to "int" exists    

error C2440: '=' : cannot convert from 'std::_Bind<false,void,SOCKET &,sockaddr *&,int>' to 'int'

Please help. 请帮忙。

I guess the problem is not in including the Mysql library, i got this problem once and i fixed it removing the 我想问题不在于包括Mysql库,我曾经遇到过这个问题,并且我解决了删除问题

using namespace std;

or another solution is to call bind from the global namespace to avoid this kind of problems; 或者另一种解决方案是从全局名称空间调用bind以避免这种问题;

i forgot to write that calling bind from the global namespace is done like this : 我忘了写从全局名称空间的调用绑定是这样完成的:

::bind(...);

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM