smrtlink/src/Socket.h

47 lines
841 B
C
Raw Normal View History

2015-09-23 20:29:29 +00:00
/*
* Socket.h
*
* Created on: 02.09.2015
* Author: jdi
*/
#ifndef SOCKET_H_
#define SOCKET_H_
#include <asio.hpp>
2015-09-25 23:24:03 +00:00
#include "Packet.h"
2015-10-11 21:07:04 +00:00
#include "Types/Types.h"
2015-09-23 20:29:29 +00:00
2015-10-14 22:00:07 +00:00
#define SRC_PORT 29809
#define DST_PORT 29808
2015-09-24 18:01:26 +00:00
#define MAX_LENGTH 1024
2015-09-23 20:29:29 +00:00
class Socket {
public:
2015-09-24 18:01:26 +00:00
Socket(asio::io_service&);
2015-09-25 23:24:03 +00:00
virtual ~Socket() {
}
2015-09-24 18:01:26 +00:00
void init(short, short);
2015-09-23 20:29:29 +00:00
void send(bytes);
void listen();
2015-10-06 19:14:01 +00:00
void setHostIp(ipAddr);
2015-09-25 23:24:03 +00:00
int (*callback)(Packet)=[](Packet a) {
return 0;
};
2015-09-23 20:29:29 +00:00
private:
2015-09-24 18:01:26 +00:00
asio::ip::udp::socket send_socket_;
asio::ip::udp::socket receive_socket_;
2015-09-27 12:38:25 +00:00
//asio::ip::udp::resolver resolver;
2015-09-23 20:29:29 +00:00
asio::ip::udp::endpoint broadcast_endpoint_;
asio::ip::udp::endpoint remote_endpoint_;
2015-09-24 18:01:26 +00:00
asio::ip::udp::endpoint wildcard_endpoint_;
2015-09-23 20:29:29 +00:00
asio::ip::udp::endpoint local_endpoint_;
2015-09-26 01:48:10 +00:00
bytes data = bytes(MAX_LENGTH);
2015-10-06 19:14:01 +00:00
ipAddr local_ip;
2015-09-23 20:29:29 +00:00
};
#endif /* SOCKET_H_ */