simple-socket library 1.9.0
Loading...
Searching...
No Matches
UDPSocket.h
Go to the documentation of this file.
1#ifndef NET_UDPSocket_h__
2#define NET_UDPSocket_h__
3
4#include "InternetSocket.h"
5
6namespace NET
7{
9 class UDPSocket : public InternetSocket
10 {
11 public:
17
19
32 [[nodiscard]] static UDPSocket adoptNativeHandle( int sockfd);
33
53 IOResult sendTo( const void* buffer, size_t len, std::string_view foreignAddress, unsigned short foreignPort);
54
69 IOResult receiveFrom( void* buffer, size_t len, std::string& sourceAddress, unsigned short& sourcePort);
70
88 IOResult timedReceiveFrom( void* buffer, size_t len, std::string& sourceAddress, unsigned short& sourcePort, int timeout);
89
95 void setMulticastTTL( unsigned char multicastTTL);
96
102 void setMulticastInterfaceAddr( const std::string& address);
103
112 void joinGroup( const std::string& multicastGroup);
113
122 void leaveGroup( const std::string& multicastGroup);
123
124 protected:
125 // allow construction by adopt
127 };
128
129} // namespace NET
130
131#endif // NET_UDPSocket_h__
InternetSocket(AddressFamily family, int type, int protocol)
allows a subclass to create new socket
UDPSocket(AddressFamily family=IPv4)
IOResult timedReceiveFrom(void *buffer, size_t len, std::string &sourceAddress, unsigned short &sourcePort, int timeout)
IOResult sendTo(const void *buffer, size_t len, std::string_view foreignAddress, unsigned short foreignPort)
void setMulticastTTL(unsigned char multicastTTL)
InternetSocket(AddressFamily family, int type, int protocol)
allows a subclass to create new socket
void leaveGroup(const std::string &multicastGroup)
static UDPSocket adoptNativeHandle(int sockfd)
Take ownership of an existing native UDP socket descriptor.
void joinGroup(const std::string &multicastGroup)
void setMulticastInterfaceAddr(const std::string &address)
IOResult receiveFrom(void *buffer, size_t len, std::string &sourceAddress, unsigned short &sourcePort)
AddressFamily
used by internet socket types