This commit is contained in:
/jdi/ 2015-09-27 12:23:12 +02:00
parent 364bb25ab7
commit b76fb38bc2
16 changed files with 363 additions and 196 deletions

41
src/Socket.h Normal file
View file

@ -0,0 +1,41 @@
/*
* Socket.h
*
* Created on: 02.09.2015
* Author: jdi
*/
#ifndef SOCKET_H_
#define SOCKET_H_
#include <asio.hpp>
#include "Packet.h"
#include "Types.h"
#define MAX_LENGTH 1024
class Socket {
public:
Socket(asio::io_service&);
virtual ~Socket() {
}
void init(short, short);
void send(bytes);
void listen();
int (*callback)(Packet)=[](Packet a) {
return 0;
};
private:
asio::ip::udp::socket send_socket_;
asio::ip::udp::socket receive_socket_;
asio::ip::udp::resolver resolver;
asio::ip::udp::endpoint broadcast_endpoint_;
asio::ip::udp::endpoint remote_endpoint_;
asio::ip::udp::endpoint wildcard_endpoint_;
asio::ip::udp::endpoint local_endpoint_;
bytes data = bytes(MAX_LENGTH);
};
#endif /* SOCKET_H_ */