hlswmaster-ng/multisock.h

58 lines
1.0 KiB
C++

#ifndef _MULTISOCK_H_
#define _MULTISOCK_H_
#include <net/if.h>
#include <netinet/in.h>
#include "list.h"
#include "config.h"
#include "gameids.h"
class MultiSock {
public:
MultiSock(Config& conf);
~MultiSock();
void send(struct in_addr *dstip, int dport, const char* data, int size);
void send(struct game_ports* arr, const char* data, int size);
void send(int* arr, const char* data, int size);
int waitOnSocket();
protected:
MultiSock(const MultiSock& x);
MultiSock& operator=(const MultiSock& x);
private:
class Socket {
public:
static Socket* createSocket(const char* name, int port);
int show(char* buf, int size);
int getFD() { return fd; }
~Socket();
protected:
Socket(const Socket& s);
Socket& operator=(const Socket& s);
private:
Socket();
bool bindToDevice(const char* name);
bool bindToPort(int port);
int fd;
char devname[IFNAMSIZ];
struct sockaddr_in addr;
};
void addIface(const char* name, int port);
List<Socket> ifaceList;
fd_set fdsel;
};
#endif // _MULTISOCK_H_