udp_socket.h
1
2 #pragma once
3
4 #include "network_condition_variable.h"
5 #include <memory>
6 #include <vector>
7
8 namespace clan
9 {
10 class SocketName;
11 class UDPSocketImpl;
12
14 class UDPSocket : public NetworkEvent
15 {
16 public:
18 UDPSocket();
19
20 ~UDPSocket();
21
23 void close();
24
26 void bind(const SocketName &endpoint);
27
29 void send(const void *data, int size, const SocketName &endpoint);
30
33 int read(void *data, int size, SocketName &endpoint);
34
35 protected:
36 SocketHandle *get_socket_handle() override;
37
38 private:
39 std::shared_ptr<UDPSocketImpl> impl;
40 };
41 }
clan
Definition: clanapp.h:35
clan::UDPSocket::read
int read(void *data, int size, SocketName &endpoint)
Read receved UDP packet.
clan::UDPSocket::UDPSocket
UDPSocket()
Create socket object.
clan::UDPSocket
UDP/IP socket class.
Definition: udp_socket.h:14
clan::UDPSocket::~UDPSocket
~UDPSocket()
clan::UDPSocket::close
void close()
Close connection.
clan::UDPSocket::get_socket_handle
SocketHandle * get_socket_handle() override
clan::SocketName
Socket name; container class for an IP address and port.
Definition: socket_name.h:44
clan::UDPSocket::bind
void bind(const SocketName &endpoint)
Bind socket to end point.
clan::UDPSocket::send
void send(const void *data, int size, const SocketName &endpoint)
Send UDP packet to end point.
clan::NetworkEvent
Base class for all classes that generate network events.
Definition: network_condition_variable.h:14