29 #ifndef Pt_Net_UdpSocket_h
30 #define Pt_Net_UdpSocket_h
32 #include <Pt/Net/Api.h>
33 #include <Pt/Net/Endpoint.h>
34 #include <Pt/System/IODevice.h>
66 {
return (_flags & Broadcast) != 0; }
71 { _flags |= Broadcast; }
164 bool isBound()
const;
194 bool beginConnect(
const Endpoint& ep);
214 {
return _connected; }
218 bool isConnected()
const;
222 void joinMulticastGroup(
const std::string& ipaddr);
228 void localEndpoint(
Endpoint& ep)
const;
232 const Endpoint& remoteEndpoint()
const;
236 virtual void onClose();
239 void onSetTimeout(std::size_t timeout);
242 virtual bool onRun();
245 virtual std::size_t onBeginRead(
System::EventLoop& loop,
char* buffer, std::size_t n,
bool& eof);
248 virtual std::size_t onEndRead(
System::EventLoop& loop,
char* buffer, std::size_t n,
bool& eof);
251 virtual std::size_t onRead(
char* buffer, std::size_t count,
bool& eof);
254 virtual std::size_t onBeginWrite(
System::EventLoop& loop,
const char* buffer, std::size_t n);
257 virtual std::size_t onEndWrite(
System::EventLoop& loop,
const char* buffer, std::size_t n);
260 virtual std::size_t onWrite(
const char* buffer, std::size_t count);
263 virtual void onCancel();
267 class UdpSocketImpl* _impl;
Signal< UdpSocket & > & connected()
Notifies that the socket was connected.
Definition: UdpSocket.h:213
void setHopLimit(int n)
Sets the hop limit.
Definition: UdpSocket.h:80
void setBroadcast()
enables UDP broadcast.
Definition: UdpSocket.h:70
Signal< UdpSocket & > & bound()
Notifies that the socket was bound.
Definition: UdpSocket.h:159
UDP server and client socket.
Definition: UdpSocket.h:100
bool isBroadcast() const
Returns true if UDP broadcast is enabled.
Definition: UdpSocket.h:65
Multicast Signal to call multiple slots.
Definition: Signal.h:109
Endpoint for I/O operations.
Definition: IODevice.h:55
Represents a Network Host.
Definition: Endpoint.h:46
Thread-safe event loop supporting I/O multiplexing and Timers.
Definition: EventLoop.h:72
uint_type uint32_t
Unsigned 32-bit integer type.
Definition: Types.h:42
int hopLimit() const
Returns the hop limit.
Definition: UdpSocket.h:75
UDP socket options.
Definition: UdpSocket.h:44