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; }
214 {
return _connected; }
236 virtual void onClose();
239 void onSetTimeout(std::size_t timeout);
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);
267 class UdpSocketImpl* _impl;
Core module.
Definition: pt-gfx-images.dox:14
UdpSocket()
Default constructor.
bool isBound() const
Returns true if bound.
void setBroadcast()
enables UDP broadcast.
Definition: UdpSocket.h:70
void connect(const Endpoint &ep, const UdpSocketOptions &o)
Connect to an endpoint.
bool beginConnect(const Endpoint &ep, const UdpSocketOptions &o)
Begin connect to an endpoint.
UdpSocketOptions()
Default constructor.
void setHopLimit(int n)
Sets the hop limit.
Definition: UdpSocket.h:80
int hopLimit() const
Returns the hop limit.
Definition: UdpSocket.h:75
bool beginConnect(const Endpoint &ep)
Begin connect to an endpoint.
Multicast Signal to call multiple slots.
Definition: Signal.h:110
void endBind()
end bind to local endpoint.
void localEndpoint(Endpoint &ep) const
Gets the local endpoint.
virtual void onCancel()
Blocks until operation has cancelled.
virtual bool onRun()
Check if ready and run.
bool beginBind(const Endpoint &ep, const UdpSocketOptions &o)
Begin bind to local endpoint.
bool beginBind(const Endpoint &ep)
Begin bind to local endpoint.
UdpSocketOptions & operator=(const UdpSocketOptions &opts)
Assignment operator.
void bind(const Endpoint &ep)
Bind to local endpoint.
bool isBroadcast() const
Returns true if UDP broadcast is enabled.
Definition: UdpSocket.h:65
void connect(const Endpoint &ep)
Connect to an endpoint.
UdpSocketOptions(const UdpSocketOptions &opts)
Copy constructor.
Represents a Network Host.
Definition: Endpoint.h:47
UDP server and client socket.
Definition: UdpSocket.h:101
const Endpoint & remoteEndpoint() const
Gets the remote endpoint.
void setTarget(const Endpoint &ep, const UdpSocketOptions &o)
Set target endpoint.
Signal< UdpSocket & > & connected()
Notifies that the socket was connected.
Definition: UdpSocket.h:213
Thread-safe event loop supporting I/O multiplexing and Timers.
Definition: EventLoop.h:74
Endpoint for I/O operations.
Definition: IODevice.h:56
~UdpSocketOptions()
Destructor.
void joinMulticastGroup(const std::string &ipaddr)
Joins a multicast group.
uint_type uint32_t
Unsigned 32-bit integer type.
Definition: Types.h:42
void bind(const Endpoint &ep, const UdpSocketOptions &o)
Bind to local endpoint.
UDP socket options.
Definition: UdpSocket.h:45
UdpSocket(System::EventLoop &loop)
Construct with event loop.
void endConnect()
End connect to an endpoint.
bool isConnected() const
Returns true if connected.
void setTarget(const Endpoint &ep)
Set target endpoint.
Signal< UdpSocket & > & bound()
Notifies that the socket was bound.
Definition: UdpSocket.h:159