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>
68 {
return (_flags & Broadcast) != 0; }
73 { _flags |= Broadcast; }
312 {
return _connected; }
334 virtual void onClose();
337 void onSetTimeout(std::size_t timeout);
349 virtual std::size_t onRead(
char* buffer, std::size_t count,
bool& eof);
358 virtual std::size_t onWrite(
const char* buffer, std::size_t count);
365 class UdpSocketImpl* _impl;
Host and service address.
Definition Endpoint.h:77
UDP socket bind and send options.
Definition UdpSocket.h:47
int hopLimit() const
Returns the hop limit.
Definition UdpSocket.h:77
bool isBroadcast() const
Returns true if UDP broadcast is enabled.
Definition UdpSocket.h:67
~UdpSocketOptions()
Destroys the options.
UdpSocketOptions()
Creates default options.
UdpSocketOptions(const UdpSocketOptions &opts)
Copies the options.
void setHopLimit(int n)
Sets the hop limit.
Definition UdpSocket.h:82
UdpSocketOptions & operator=(const UdpSocketOptions &opts)
Assigns the options.
void setBroadcast()
Enables UDP broadcast.
Definition UdpSocket.h:72
~UdpSocket()
Destroys the socket.
bool isBound() const
Returns true if the socket is bound.
void endConnect()
Ends connecting to an endpoint.
UdpSocket(System::EventLoop &loop)
Creates a socket and attaches it to loop.
bool beginConnect(const Endpoint &ep, const UdpSocketOptions &o)
Begins connecting to ep with o.
const Endpoint & remoteEndpoint() const
Returns the remote endpoint.
virtual void onCancel()
Blocks until operation has cancelled.
Signal< UdpSocket & > & connected()
Returns the signal that the socket was connected.
Definition UdpSocket.h:311
UdpSocket()
Creates a closed socket.
bool beginBind(const Endpoint &ep)
Begins binding to ep.
void joinMulticastGroup(const std::string &ipaddr)
Joins multicast group ipaddr.
virtual bool onRun()
Check if ready and run.
bool isConnected() const
Returns true if the socket is connected.
bool beginConnect(const Endpoint &ep)
Begins connecting to ep.
void connect(const Endpoint &ep, const UdpSocketOptions &o)
Connects to ep with o.
void bind(const Endpoint &ep, const UdpSocketOptions &o)
Binds to ep with o.
void bind(const Endpoint &ep)
Binds to local endpoint ep.
void setTarget(const Endpoint &ep)
Sets the send target to ep.
Signal< UdpSocket & > & bound()
Returns the signal that the socket was bound.
Definition UdpSocket.h:254
void setTarget(const Endpoint &ep, const UdpSocketOptions &o)
Sets the send target to ep with o.
void localEndpoint(Endpoint &ep) const
Writes the local endpoint into ep.
void connect(const Endpoint &ep)
Connects to ep.
bool beginBind(const Endpoint &ep, const UdpSocketOptions &o)
Begins binding to ep with o.
void endBind()
Ends binding to a local endpoint.
Multicast Signal to call multiple slots.
Definition Signal.h:190
Event loop of a thread or process.
Definition EventLoop.h:83
Endpoint for I/O operations.
Definition IODevice.h:96
EventLoop * loop() const
Returns the used event loop.
Definition IODevice.h:240
uint_type uint32_t
Unsigned 32-bit integer type.
Definition Api-Types.h:52
TCP and UDP network sockets.
Definition Client.h:45
Core module.
Definition Allocator.h:33