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>
64 {
return _keepAlive.i; }
66 void setKeepAlive(
int n)
143 {
return _connected; }
148 {
return _isConnected; }
160 virtual void onClose();
163 virtual void onSetTimeout(std::size_t timeout);
169 virtual std::size_t onBeginRead(
System::EventLoop& loop,
char* buffer, std::size_t n,
bool& eof);
172 virtual std::size_t onEndRead(
System::EventLoop& loop,
char* buffer, std::size_t n,
bool& eof);
175 virtual std::size_t onRead(
char* buffer, std::size_t count,
bool& eof);
178 virtual std::size_t onBeginWrite(
System::EventLoop& loop,
const char* buffer, std::size_t n);
181 virtual std::size_t onEndWrite(
System::EventLoop& loop,
const char* buffer, std::size_t n);
184 virtual std::size_t onWrite(
const char* buffer, std::size_t count);
191 class TcpSocketImpl* _impl;
207 #endif // Pt_Net_TcpSocket_h
Core module.
Definition: pt-gfx-images.dox:14
TcpSocket(const Endpoint &ep)
Connects to a host.
bool isConnected() const
Returns true if connected.
Definition: TcpSocket.h:147
TCP client socket.
Definition: TcpSocket.h:81
virtual bool onRun()
Check if ready and run.
TcpSocketOptions(const TcpSocketOptions &opts)
Copy Constructor.
void accept(TcpServer &server)
Accepts a connection.
TcpSocketOptions & operator=(const TcpSocketOptions &opts)
Assignment operator.
TCP server socket.
Definition: TcpServer.h:100
void connect(const Endpoint &ep, const TcpSocketOptions &o)
Connect to a host.
Multicast Signal to call multiple slots.
Definition: Signal.h:110
void accept(TcpServer &server, const TcpSocketOptions &o)
Accepts a connection.
TcpSocket(System::EventLoop &loop)
Construct with event loop.
TcpSocket()
Default Constructor.
virtual void onCancel()
Blocks until operation has cancelled.
void beginConnect(const Endpoint &ep)
Begin connecting to a host.
TcpSocket(TcpServer &server)
Accepts a connection.
Represents a Network Host.
Definition: Endpoint.h:47
Signal< TcpSocket & > & connected()
Notifies that the socket was connected.
Definition: TcpSocket.h:142
Thread-safe event loop supporting I/O multiplexing and Timers.
Definition: EventLoop.h:74
Endpoint for I/O operations.
Definition: IODevice.h:56
TcpSocketOptions()
Default Constructor.
void remoteEndpoint(Endpoint &ep) const
Gets the remote endpoint.
void connect(const Endpoint &ep)
Connect to a host.
uint_type uint32_t
Unsigned 32-bit integer type.
Definition: Types.h:42
void endConnect()
Ends connecting to a host.
void localEndpoint(Endpoint &ep) const
Gets the local endpoint.
TCP socket options.
Definition: TcpSocket.h:49
void beginConnect(const Endpoint &ep, const TcpSocketOptions &o)
Begin connecting to a host.
~TcpSocketOptions()
Destructor.