fix network

master
zcy 2021-06-09 23:11:42 +08:00
parent 70571fa290
commit 10a400f521
2 changed files with 14 additions and 2 deletions

View File

@ -4,8 +4,6 @@
#include "TcpClient.h"
void conn_writecb(struct bufferevent *, void *);
void conn_readcb(struct bufferevent *, void *);
void conn_eventcb(struct bufferevent *, short, void *);
@ -126,8 +124,15 @@ TcpClientLibevent::TcpClientLibevent(std::string addrinfo, int port, TcpClientLi
mObserver(nullptr)
{
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_family = AF_INET;
#endif
mSrv.sin_port = htons(port);
mBase = event_base_new();

View File

@ -8,6 +8,13 @@
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
#ifdef linux
#include<sys/types.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#define EVENT__HAVE_PTHREADS
#endif
extern "C"{
#include "third/include/event2/bufferevent.h"
#include "third/include/event2/buffer.h"