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 }
Definition: clanapp.h:35
int read(void *data, int size, SocketName &endpoint)
Read receved UDP packet.
UDPSocket()
Create socket object.
UDP/IP socket class.
Definition: udp_socket.h:14
void close()
Close connection.
SocketHandle * get_socket_handle() override
Socket name; container class for an IP address and port.
Definition: socket_name.h:44
void bind(const SocketName &endpoint)
Bind socket to end point.
void send(const void *data, int size, const SocketName &endpoint)
Send UDP packet to end point.
Base class for all classes that generate network events.
Definition: network_condition_variable.h:14