Cogs.Core
|
Public Member Functions | |
ConnectionTCP (Socket socket, const SockaddrIn &addr) | |
Constructs a connection that is attached to the specified socket. | |
virtual | ~ConnectionTCP () |
Destroys this connection. | |
SocketType | type () const override |
IPProto | proto () const override |
void | enableAutoReconnect () |
void | disableAutoReconnect () |
virtual bool | isAutoConnectEnabled () const override |
virtual bool | isConnected () const override |
void | setConnectTimeout (int64_t milliseconds) |
void | setNoDelay (bool val=true) |
Set the TCP_NODELAY flag (Enable / Disables Nagles algorithm). | |
void | shutdown () |
Shutdown this connection. | |
virtual bool | connect (const SockaddrIn &addr) |
Sets up this connection ready to connect to the specified remote address and port. | |
virtual bool | reconnect () override |
Reconnects this connection to the remote host previously specified through a call to connect. | |
virtual bool | disconnect () override |
Disconnects this connection. | |
bool | listen (uint16_t port) |
bool | listen (AddrIn ip, uint16_t port) |
Sets this connection up as a listener that will listen for and respond to incoming connection requests on the specified port. | |
virtual bool | processIncoming () override |
Manages accepting incoming connections when this connection is a listener. | |
virtual ConnectionTCP * | accept (Socket, const SockaddrIn &) |
![]() | |
Family | family () const |
virtual SocketType | type () const =0 |
virtual IPProto | proto () const =0 |
Socket | getSocket () const |
void | remove () |
void | removeAndDelete () |
const SockaddrIn & | getAddress () const |
int64_t | getReconnectTime () const |
virtual bool | isAutoConnectEnabled () const |
virtual bool | isConnected () const |
bool | shouldRemove () const |
bool | shouldDelete () const |
void | setNonblocking (bool val=true) |
Sets socket non-blocking mode to val. | |
void | setDoNotProcess () |
virtual bool | reconnect () |
virtual bool | disconnect ()=0 |
bool | bind (uint16_t port) |
virtual bool | bind (AddrIn ip, uint16_t port) |
Sets this connection up as a listener that will listen for and respond to incoming connection requests on the specified port. | |
bool | send (const void *data, uint64_t byteCount, uint64_t &bytesSent) |
Attempts to send as much of the specified data as possible. | |
bool | receive (void *buffer, uint64_t byteCount, uint64_t &bytesReceived) |
Attempts to read the specified number of bytes from the network socket this connection represents. | |
bool | sendTo (const void *data, uint64_t byteCount, uint64_t &bytesSent, const SockaddrIn &addr) |
Attempts to send as much of the specified data as possible. | |
bool | recvFrom (void *buffer, uint64_t byteCount, uint64_t &bytesReceived, SockaddrIn &addr) |
Attempts to read the specified number of bytes from the network socket this connection represents. | |
virtual bool | processOutgoing () |
virtual bool | processIncoming () |
Private Attributes | |
int64_t | connectTimeout = 0 |
Static Private Attributes | |
static constexpr uint32_t | cListening = 0x00010000 |
static constexpr uint32_t | cAutoReconnect = 0x00020000 |
static constexpr uint32_t | cNoDelay = 0x00040000 |
static constexpr uint32_t | cConnected = 0x00080000 |
Additional Inherited Members | |
![]() | |
void | create () |
Internal wrapper for the socket() call. | |
void | close () |
Internal wrapper for closing the socket. | |
![]() | |
Cogs::Atomic< uint32_t > | flags = 0 |
int64_t | reconnectTime = 0 |
Socket | socket = InvalidSocket |
SockaddrIn | sockAddr = {} |
![]() | |
static constexpr uint32_t | cRemove = 0x00000001 |
static constexpr uint32_t | cDelete = 0x00000002 |
static constexpr uint32_t | cDoNotProcess = 0x00000004 |
Definition at line 111 of file Connection.h.
|
inline |
Definition at line 113 of file Connection.h.
Cogs::Network::ConnectionTCP::ConnectionTCP | ( | Socket | s, |
const SockaddrIn & | addr | ||
) |
Constructs a connection that is attached to the specified socket.
This constructor overload will be called in response to an incoming connection request being accepted.
Definition at line 376 of file Connection.cpp.
|
virtual |
Destroys this connection.
Definition at line 388 of file Connection.cpp.
|
inlinevirtual |
Definition at line 138 of file Connection.h.
|
virtual |
Sets up this connection ready to connect to the specified remote address and port.
The actual connecting will be performed by reconnect if necessary.
Definition at line 399 of file Connection.cpp.
|
inline |
Definition at line 121 of file Connection.h.
|
overridevirtual |
Disconnects this connection.
This function is usually called in response to send or receive failing. The connection can be reestablished automatically if required.
Implements Cogs::Network::ConnectionBase.
Reimplemented in Cogs::Network::ConnectionHub.
Definition at line 488 of file Connection.cpp.
Referenced by Cogs::Network::ConnectionHub::disconnect().
|
inline |
Definition at line 120 of file Connection.h.
|
inlineoverridevirtual |
Reimplemented from Cogs::Network::ConnectionBase.
Definition at line 122 of file Connection.h.
|
inlineoverridevirtual |
Reimplemented from Cogs::Network::ConnectionBase.
Definition at line 123 of file Connection.h.
bool Cogs::Network::ConnectionTCP::listen | ( | AddrIn | ip, |
uint16_t | port | ||
) |
Sets this connection up as a listener that will listen for and respond to incoming connection requests on the specified port.
Definition at line 508 of file Connection.cpp.
|
inline |
Definition at line 133 of file Connection.h.
|
overridevirtual |
Manages accepting incoming connections when this connection is a listener.
Reimplemented from Cogs::Network::ConnectionBase.
Reimplemented in Cogs::Network::ConnectionHub.
Definition at line 538 of file Connection.cpp.
References setNoDelay().
|
inlineoverridevirtual |
Implements Cogs::Network::ConnectionBase.
Definition at line 118 of file Connection.h.
|
overridevirtual |
Reconnects this connection to the remote host previously specified through a call to connect.
Reimplemented from Cogs::Network::ConnectionBase.
Definition at line 408 of file Connection.cpp.
|
inline |
Definition at line 125 of file Connection.h.
void Cogs::Network::ConnectionTCP::setNoDelay | ( | bool | val = true | ) |
Set the TCP_NODELAY flag (Enable / Disables Nagles algorithm).
Definition at line 361 of file Connection.cpp.
Referenced by processIncoming().
void Cogs::Network::ConnectionTCP::shutdown | ( | ) |
Shutdown this connection.
Definition at line 349 of file Connection.cpp.
|
inlineoverridevirtual |
Implements Cogs::Network::ConnectionBase.
Definition at line 117 of file Connection.h.
|
staticconstexprprivate |
Definition at line 143 of file Connection.h.
|
staticconstexprprivate |
Definition at line 145 of file Connection.h.
|
staticconstexprprivate |
Definition at line 142 of file Connection.h.
|
staticconstexprprivate |
Definition at line 144 of file Connection.h.
|
private |
Definition at line 147 of file Connection.h.