-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathudpinterface.h
More file actions
45 lines (32 loc) · 829 Bytes
/
udpinterface.h
File metadata and controls
45 lines (32 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef UDPINTERFACE_H
#define UDPINTERFACE_H
#include <cstring>
#include <sys/types.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <sys/socket.h>
#include <arpa/inet.h>
#endif
#include "paramsudp.h"
#include "iinterface.h"
class UDPInterface : public IInterface
{
public:
UDPInterface(TypeParams _params);
~UDPInterface() override = default;
const std::string name() override
{ return std::string("UDP"); }
bool open() override;
bool bind() override;
bool close() override;
int read(char *data, int size, int timeout) override;
int write(const char *data, int size) override;
bool check_sock(int sock, int timeout);
private:
sockaddr_in sock_addr;
bool isFirstByte = false;
int sockfd;
TypeParamsUDP params;
};
#endif // UDPINTERFACE_H