37 lines
656 B
C++
37 lines
656 B
C++
#pragma once
|
|
|
|
#ifndef _WIN32_WINNT
|
|
#define _WIN32_WINNT 0x0500
|
|
#include <WinSock2.h>
|
|
#endif
|
|
|
|
#ifdef linux
|
|
#include<sys/types.h>
|
|
#include<sys/socket.h>
|
|
#include<arpa/inet.h>
|
|
#define EVENT__HAVE_PTHREADS
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
#include <iostream>
|
|
#include <mutex>
|
|
#include <thread>
|
|
#include <map>
|
|
#include <functional>
|
|
|
|
using namespace std;
|
|
|
|
class UdpClientLibevent
|
|
{
|
|
UdpClientLibevent(std::string ipaddr,uint32_t port);
|
|
|
|
private:
|
|
uint32_t m_port; // 监听端口号
|
|
string m_bind_ip; // 绑定端口号
|
|
int m_current_conection; // 当前连接数目
|
|
uint16_t m_backlog;
|
|
struct sockaddr_in m_server_addr; // 服务器地址
|
|
struct event_base* m_event_base;
|
|
};
|
|
|