#include <nnsocket.h>
Inheritance diagram for NewNet::Socket:

Public Types | |
| enum | SocketState { SocketUninitialized, SocketListening, SocketConnecting, SocketConnected, SocketDisconnecting, SocketDisconnected, SocketException } |
| Enumeration to describe the state of the socket. More... | |
| enum | ReadyState { StateSend = 1, StateReceive = 2, StateException = 4 } |
| Enumeration to describe pending network events. More... | |
| enum | SocketError { ErrorNoError, ErrorCannotResolve, ErrorInvalidPath, ErrorCannotConnect, ErrorCannotBind, ErrorCannotListen, ErrorUnknown } |
| Enumeration to describe the error that last occured. More... | |
Public Member Functions | |
| Socket () | |
| Create a new uninitialized socket. | |
| Reactor * | reactor () const |
| Return the associated reactor. | |
| void | setReactor (Reactor *reactor) |
| Set the associated reactor. | |
| int | descriptor () const |
| Return the socket's descriptor. | |
| void | setDescriptor (int fd) |
| Set the socket's descriptor. | |
| SocketState | socketState () const |
| Return the current socket state. | |
| void | setSocketState (SocketState socketState) |
| Set the current socket state. | |
| int | readyState () const |
| Return the socket's ready state. | |
| void | setReadyState (int readyState) |
| Set the socket's ready state. | |
| SocketError | socketError () const |
| Return the socket's error state. | |
| void | setSocketError (SocketError socketError) |
| Set the socket's error state. | |
| bool | dataWaiting () const |
| Return wether there's data waiting to be sent. | |
| void | setDataWaiting (bool dataWaiting) |
| Set the data waiting flag. | |
| RateLimiter * | downRateLimiter () |
| Return the current download rate limiter. | |
| void | setDownRateLimiter (RateLimiter *limiter) |
| Set the current download rate limiter. | |
| RateLimiter * | upRateLimiter () |
| Return the current upload rate limiter. | |
| void | setUpRateLimiter (RateLimiter *limiter) |
| Set the current upload rate limiter. | |
| virtual void | process () |
| Processor function. | |
Definition at line 36 of file nnsocket.h.
This defines the current state of the socket. The value can be retrieved with socketState() and set with setSocketState().
Definition at line 42 of file nnsocket.h.
This defines what kind of network events are currently pending on the socket. The value can be retrieved using readyState() and set with setReadyState().
| StateSend | The socket is ready to send data. |
| StateReceive | Data was received, socket is ready to read. |
| StateException | Out-of-band data was received. |
Definition at line 57 of file nnsocket.h.
This defines what kind of error made the state go into exception state. It can be retrieved using socketError() and set with setSocketError().
Definition at line 68 of file nnsocket.h.
| NewNet::Socket::Socket | ( | ) | [inline] |
This creates a new socket that has an invalid descriptor, is uninitialized, has no pending events, no error and no data waiting.
Definition at line 82 of file nnsocket.h.
| Reactor* NewNet::Socket::reactor | ( | ) | const [inline] |
Return the reactor this socket is associated to, if any.
Definition at line 90 of file nnsocket.h.
Referenced by NewNet::Reactor::add(), NewNet::Reactor::remove(), and setReactor().
| void NewNet::Socket::setReactor | ( | Reactor * | reactor | ) | [inline] |
This is called by the reactor when the socket is added to the reactor. Note: stores a regular pointer to the reactor.
Definition at line 98 of file nnsocket.h.
References reactor().
Referenced by NewNet::Reactor::add(), and NewNet::Reactor::remove().
| int NewNet::Socket::descriptor | ( | ) | const [inline] |
This returns the socket's descriptor.
Definition at line 105 of file nnsocket.h.
Referenced by NewNet::UnixClientSocket::connect(), NewNet::TcpClientSocket::connect(), NewNet::UnixServerSocket::disconnect(), NewNet::ServerSocket::disconnect(), NewNet::ClientSocket::disconnect(), NewNet::ServerSocket::process(), and NewNet::ClientSocket::process().
| void NewNet::Socket::setDescriptor | ( | int | fd | ) | [inline] |
This initializes the socket's descriptor. Usually called by subclasses when connecting or by socket factories when accepting a new client.
Definition at line 114 of file nnsocket.h.
Referenced by NewNet::UnixClientSocket::connect(), NewNet::TcpClientSocket::connect(), NewNet::UnixServerSocket::listen(), and NewNet::TcpServerSocket::listen().
| SocketState NewNet::Socket::socketState | ( | ) | const [inline] |
Retrieves the current socket state.
Definition at line 121 of file nnsocket.h.
Referenced by NewNet::UnixClientSocket::connect(), NewNet::TcpClientSocket::connect(), NewNet::UnixServerSocket::disconnect(), NewNet::ServerSocket::disconnect(), NewNet::ClientSocket::disconnect(), and NewNet::ClientSocket::process().
| void NewNet::Socket::setSocketState | ( | SocketState | socketState | ) | [inline] |
Changes the current socket state.
Definition at line 128 of file nnsocket.h.
Referenced by NewNet::UnixClientSocket::connect(), NewNet::TcpClientSocket::connect(), NewNet::ServerSocket::disconnect(), NewNet::ClientSocket::disconnect(), NewNet::UnixServerSocket::listen(), NewNet::TcpServerSocket::listen(), NewNet::ClientSocket::process(), and setSocketError().
| int NewNet::Socket::readyState | ( | ) | const [inline] |
Returns what kind of events are pending on the socket.
Definition at line 135 of file nnsocket.h.
Referenced by NewNet::ServerSocket::process(), and NewNet::ClientSocket::process().
| void NewNet::Socket::setReadyState | ( | int | readyState | ) | [inline] |
Usually called by subclasses and the reactor to specify what kind of network events are pending.
Definition at line 143 of file nnsocket.h.
Referenced by NewNet::ServerSocket::process(), and NewNet::ClientSocket::process().
| SocketError NewNet::Socket::socketError | ( | ) | const [inline] |
Returns what kind of error last occured on the socket.
Definition at line 150 of file nnsocket.h.
| void NewNet::Socket::setSocketError | ( | SocketError | socketError | ) | [inline] |
Usually called by subclasses to specify what kind of error occured on the socket.
Definition at line 158 of file nnsocket.h.
References setSocketState(), and SocketException.
Referenced by NewNet::UnixClientSocket::connect(), NewNet::TcpClientSocket::connect(), NewNet::UnixServerSocket::listen(), NewNet::TcpServerSocket::listen(), and NewNet::ClientSocket::process().
| bool NewNet::Socket::dataWaiting | ( | ) | const [inline] |
Called by the reactor to determine wether the socket has data waiting to be sent.
Definition at line 167 of file nnsocket.h.
Referenced by NewNet::ClientSocket::process().
| void NewNet::Socket::setDataWaiting | ( | bool | dataWaiting | ) | [inline] |
Called by subclasses to specify that there's data waiting to be sent
Definition at line 174 of file nnsocket.h.
Referenced by NewNet::ClientSocket::process(), and NewNet::ClientSocket::send().
| RateLimiter* NewNet::Socket::downRateLimiter | ( | ) | [inline] |
Return the current download rate limiter.
Definition at line 181 of file nnsocket.h.
Referenced by NewNet::ClientSocket::process().
| void NewNet::Socket::setDownRateLimiter | ( | RateLimiter * | limiter | ) | [inline] |
Set the current download rate limiter. Note: stores a RefPtr to the rate limiter.
Definition at line 189 of file nnsocket.h.
| RateLimiter* NewNet::Socket::upRateLimiter | ( | ) | [inline] |
Return the current upload rate limiter.
Definition at line 196 of file nnsocket.h.
Referenced by NewNet::ClientSocket::process().
| void NewNet::Socket::setUpRateLimiter | ( | RateLimiter * | limiter | ) | [inline] |
Set the current upload rate limiter. Note: stores a RefPtr to the rate limiter.
Definition at line 204 of file nnsocket.h.
| virtual void NewNet::Socket::process | ( | ) | [inline, virtual] |
This is called by the reactor when there are pending network events.
Reimplemented in NewNet::ClientSocket, and NewNet::ServerSocket.
Definition at line 211 of file nnsocket.h.
1.5.1