fix network
parent
70571fa290
commit
10a400f521
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
#include "TcpClient.h"
|
#include "TcpClient.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void conn_writecb(struct bufferevent *, void *);
|
void conn_writecb(struct bufferevent *, void *);
|
||||||
void conn_readcb(struct bufferevent *, void *);
|
void conn_readcb(struct bufferevent *, void *);
|
||||||
void conn_eventcb(struct bufferevent *, short, void *);
|
void conn_eventcb(struct bufferevent *, short, void *);
|
||||||
|
@ -126,8 +124,15 @@ TcpClientLibevent::TcpClientLibevent(std::string addrinfo, int port, TcpClientLi
|
||||||
mObserver(nullptr)
|
mObserver(nullptr)
|
||||||
{
|
{
|
||||||
memset(&mSrv, 0, sizeof(mSrv));
|
memset(&mSrv, 0, sizeof(mSrv));
|
||||||
|
#ifdef linux
|
||||||
|
mSrv.sin_addr.s_addr = inet_addr(addrinfo.c_str());
|
||||||
|
mSrv.sin_family = AF_INET;
|
||||||
|
#endif
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
mSrv.sin_addr.S_un.S_addr = inet_addr(addrinfo.c_str());
|
mSrv.sin_addr.S_un.S_addr = inet_addr(addrinfo.c_str());
|
||||||
mSrv.sin_family = AF_INET;
|
mSrv.sin_family = AF_INET;
|
||||||
|
#endif
|
||||||
mSrv.sin_port = htons(port);
|
mSrv.sin_port = htons(port);
|
||||||
|
|
||||||
mBase = event_base_new();
|
mBase = event_base_new();
|
||||||
|
|
|
@ -8,6 +8,13 @@
|
||||||
#ifndef _WIN32_WINNT
|
#ifndef _WIN32_WINNT
|
||||||
#define _WIN32_WINNT 0x0500
|
#define _WIN32_WINNT 0x0500
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef linux
|
||||||
|
#include<sys/types.h>
|
||||||
|
#include<sys/socket.h>
|
||||||
|
#include<arpa/inet.h>
|
||||||
|
#define EVENT__HAVE_PTHREADS
|
||||||
|
#endif
|
||||||
|
|
||||||
extern "C"{
|
extern "C"{
|
||||||
#include "third/include/event2/bufferevent.h"
|
#include "third/include/event2/bufferevent.h"
|
||||||
#include "third/include/event2/buffer.h"
|
#include "third/include/event2/buffer.h"
|
||||||
|
|
Loading…
Reference in New Issue