29#ifndef Pt_Net_TcpSocket_h
30#define Pt_Net_TcpSocket_h
32#include <Pt/Net/Api.h>
33#include <Pt/Net/Endpoint.h>
34#include <Pt/System/IODevice.h>
72 {
return _keepAlive.i; }
210 {
return _connected; }
215 {
return _isConnected; }
227 virtual void onClose();
230 virtual void onSetTimeout(std::size_t timeout);
242 virtual std::size_t onRead(
char* buffer, std::size_t count,
bool& eof);
251 virtual std::size_t onWrite(
const char* buffer, std::size_t count);
258 class TcpSocketImpl* _impl;
Host and service address.
Definition Endpoint.h:77
Listens for TCP connections.
Definition TcpServer.h:159
TCP socket connection options.
Definition TcpSocket.h:51
TcpSocketOptions()
Creates default options.
~TcpSocketOptions()
Destroys the options.
TcpSocketOptions(const TcpSocketOptions &opts)
Copies the options.
TcpSocketOptions & operator=(const TcpSocketOptions &opts)
Assigns the options.
void setKeepAlive(int n)
Sets the keep-alive interval in seconds.
Definition TcpSocket.h:78
int keepAlive() const
Returns the keep-alive interval in seconds, or a negative value if unset.
Definition TcpSocket.h:71
void endConnect()
Ends connecting to a host.
~TcpSocket()
Destroys the socket.
Signal< TcpSocket & > & connected()
Returns the signal that the socket was connected.
Definition TcpSocket.h:209
virtual void onCancel()
Blocks until operation has cancelled.
TcpSocket(TcpServer &server)
Creates a socket and accepts a connection from server.
void beginConnect(const Endpoint &ep, const TcpSocketOptions &o)
Begins connecting to ep with o.
void remoteEndpoint(Endpoint &ep) const
Writes the remote endpoint into ep.
TcpSocket(System::EventLoop &loop)
Creates a socket and attaches it to loop.
virtual bool onRun()
Check if ready and run.
bool isConnected() const
Returns true if the socket is connected.
Definition TcpSocket.h:214
void beginConnect(const Endpoint &ep)
Begins connecting to ep.
void accept(TcpServer &server)
Accepts a connection from server.
TcpSocket()
Creates a closed socket.
void accept(TcpServer &server, const TcpSocketOptions &o)
Accepts a connection from server with o.
void localEndpoint(Endpoint &ep) const
Writes the local endpoint into ep.
void connect(const Endpoint &ep, const TcpSocketOptions &o)
Connects to ep with o.
void connect(const Endpoint &ep)
Connects to ep.
TcpSocket(const Endpoint &ep)
Creates a socket and connects to ep.
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