套接字绑定功能的编译错误 [英] Compilation errors with socket bind function

查看:73
本文介绍了套接字绑定功能的编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一开始我包含以下文件,并且使用bind函数可以使一切正常

At the very beginning I include the following files and everything goes fine with the bind function

#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>

绑定函数

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

当我同时包含mysql库时,事情开始变得混乱

Things start messing up when I include the mysql libraries as well

#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'

请帮助。

推荐答案

我想问题不在于包括Mysql库,我一次遇到了这个问题,我修复了它,删除了

I guess the problem is not in including the Mysql library, i got this problem once and i fixed it removing the

using namespace std;

或另一种解决方案是从全局命名空间调用bind以避免这种问题;

or another solution is to call bind from the global namespace to avoid this kind of problems;

我忘了这样写:从全局名称空间调用绑定是这样完成的:

i forgot to write that calling bind from the global namespace is done like this :

::bind(...);

希望这会有所帮助。

这篇关于套接字绑定功能的编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆