-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUDPClient.h
More file actions
35 lines (27 loc) · 788 Bytes
/
UDPClient.h
File metadata and controls
35 lines (27 loc) · 788 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
#ifndef UDPCLIENT_H
#define UDPCLIENT_H
#include <arpa/inet.h>
#include <netinet/in.h>
#include <cstdint>
#include <string>
#include <vector>
#include "IClient.h"
class UDPClient : public IClient {
public:
UDPClient();
UDPClient(const UDPClient&) = delete;
UDPClient& operator=(const UDPClient&) = delete;
UDPClient(UDPClient&&) = delete;
UDPClient& operator=(UDPClient&&) = delete;
int Init(std::string ip_address, int port) override;
bool Send(const std::vector<std::uint8_t>& data) override;
bool Receive(std::vector<std::uint8_t>& data) override;
void Destroy() override;
~UDPClient() override;
private:
int sockfd_;
sockaddr_in serverStruct_;
char server_address_[INET_ADDRSTRLEN];
int server_portnum_;
};
#endif