Public Types | |
enum | SocketType { Unknown = -1, TcpSocket, UdpSocket } |
Defines the socket type. Currently only TcpSockets are supported. More... | |
Public Member Functions | |
NAbstractSocket (void) | |
Constructs an abstract socket object. | |
NAbstractSocket (const NHostAddress &host) | |
Constructs an abstract socket object. | |
NAbstractSocket (const NHostAddress &host, nuint16 port) | |
Constructs an abstract socket object. | |
NAbstractSocket (const NString &host, nuint16 port) | |
Constructs an abstract socket object. | |
virtual | ~NAbstractSocket (void) |
Destroys an abstract socket object closing the related connection. | |
virtual void | setHost (const NHostAddress &host) |
Sets the host to connect to/listen. | |
virtual void | setHost (const NString &host) |
Sets the host to connect to/listen. | |
NHostAddress | getHost (void) const |
Gets the host to connect to/listen. | |
virtual void | setPort (nuint16 port) |
Sets the port to connect to/listen. | |
nuint16 | getPort (void) const |
Gets the port to connect to/listen. | |
void | setTimeout (nuint16 timeout) |
Sets the timeout for reading data. | |
nuint16 | getTimeout (void) const |
Gets the timeout for reading data. | |
void | setMaxPendingConnections (nint32 max) |
Sets the max number of pending connections. | |
nint32 | getMaxPendingConnections (void) const |
Gets the max number of pending connections. | |
virtual void | setSocketOptions (nint32 opt) |
Sets socket options. | |
virtual void | open (void)=0 |
Open the socket. | |
void | open (Mode mode) |
Open the Socket. | |
virtual void | closeDevice (void)=0 |
Closes the socket. | |
virtual void | disconnectFromHost (void)=0 |
Disconnects from the remote host. | |
virtual void | execListen (void)=0 |
Starts listening. | |
virtual void | connectToHost (void)=0 |
Connects to a host. | |
virtual nint32 | read (NDataStream *buffer)=0 |
Reads data from the socket. | |
virtual nint32 | read (NDataStream *buffer, nuint32 bytes)=0 |
Reads data from the socket. | |
virtual nint32 | readLine (NDataStream *buffer)=0 |
Reads a line from the socket. | |
virtual nint32 | write (const NDataStream &data, nuint32 bytes)=0 |
Writes data to the socket. | |
virtual nint32 | writeLine (const NDataStream &data, nuint32 bytes)=0 |
Writes a line of data to the socket. | |
Static Public Attributes | |
static const nint32 | DEFAULT_SOCK_OPTS = 0 |
Default options. | |
static const nint32 | REUSE_ADDRESS = SO_REUSEADDR |
Allow the reuse of local address. | |
static const nint32 | KEEPALIVE = SO_KEEPALIVE |
Enable sending of keep-alive messages. | |
Protected Attributes | |
NHostAddress | m_host |
nuint16 | m_port |
nuint16 | m_timeout |
nint32 | m_opt |
nint32 | m_maxPendingConn |
Definition at line 48 of file nabstractsocket.h.
enum SocketType |
Defines the socket type. Currently only TcpSockets are supported.
Unknown | Unknown socket type |
TcpSocket | TCP Socket Type |
UdpSocket | UDP socket type (not implemented) |
Definition at line 54 of file nabstractsocket.h.
NAbstractSocket | ( | const NHostAddress & | host | ) |
Constructs an abstract socket object.
host | Host to connect to/listen |
Definition at line 39 of file nabstractsocket.cpp.
References m_host, and NHostAddress::toString().
NAbstractSocket | ( | const NHostAddress & | host, | |
nuint16 | port | |||
) |
Constructs an abstract socket object.
host | Host to connect to/listen | |
port | Port to connect to/listen |
Definition at line 50 of file nabstractsocket.cpp.
References m_host, and NHostAddress::toString().
NAbstractSocket | ( | const NString & | host, | |
nuint16 | port | |||
) |
Constructs an abstract socket object.
host | Host to connect to/listen | |
port | Port to connect to/listen |
Definition at line 60 of file nabstractsocket.cpp.
void setHost | ( | const NHostAddress & | host | ) | [virtual] |
Sets the host to connect to/listen.
host | Hostname or IP to connect to/listen |
Definition at line 75 of file nabstractsocket.cpp.
References m_host.
void setHost | ( | const NString & | host | ) | [virtual] |
Sets the host to connect to/listen.
host | Hostname or IP to connect to/listen |
Definition at line 80 of file nabstractsocket.cpp.
References m_host.
NHostAddress getHost | ( | void | ) | const |
Gets the host to connect to/listen.
Definition at line 85 of file nabstractsocket.cpp.
References m_host.
void setPort | ( | nuint16 | port | ) | [virtual] |
Sets the port to connect to/listen.
port | Port to connect to/listen |
Definition at line 90 of file nabstractsocket.cpp.
References m_port.
Referenced by NTcpSocket::setPort().
nuint16 getPort | ( | void | ) | const |
Gets the port to connect to/listen.
Definition at line 95 of file nabstractsocket.cpp.
References m_port.
void setTimeout | ( | nuint16 | timeout | ) |
Sets the timeout for reading data.
timeout | Max time, in seconds, that the object will wait for a response |
Definition at line 100 of file nabstractsocket.cpp.
References m_timeout.
nuint16 getTimeout | ( | void | ) | const |
Gets the timeout for reading data.
Definition at line 105 of file nabstractsocket.cpp.
References m_timeout.
void setMaxPendingConnections | ( | nint32 | max | ) |
Sets the max number of pending connections.
max | The max number of pending connections |
Definition at line 114 of file nabstractsocket.cpp.
References m_maxPendingConn.
nint32 getMaxPendingConnections | ( | void | ) | const |
Gets the max number of pending connections.
Definition at line 119 of file nabstractsocket.cpp.
References m_maxPendingConn.
void open | ( | Mode | mode | ) | [inline, virtual] |
Open the Socket.
mode | Openning mode (ignored) |
Implements NIODevice.
Definition at line 173 of file nabstractsocket.h.
References NIODevice::open().
virtual nint32 read | ( | NDataStream * | buffer | ) | [pure virtual] |
Reads data from the socket.
buffer | Buffer to save the received data |
Implements NIODevice.
Implemented in NTcpSocket, and NTcpSocket.
virtual nint32 read | ( | NDataStream * | buffer, | |
nuint32 | bytes | |||
) | [pure virtual] |
Reads data from the socket.
buffer | Buffer to save the received data | |
bytes | Max number of bytes to read |
Implements NIODevice.
Implemented in NTcpSocket, and NTcpSocket.
virtual nint32 readLine | ( | NDataStream * | buffer | ) | [pure virtual] |
Reads a line from the socket.
buffer | Buffer to save the received data |
Implements NIODevice.
Implemented in NTcpSocket, and NTcpSocket.
virtual nint32 write | ( | const NDataStream & | data, | |
nuint32 | bytes | |||
) | [pure virtual] |
Writes data to the socket.
data | Data to be written to the socket | |
bytes | Max number of bytes to write to the socket |
Implements NIODevice.
Implemented in NTcpSocket, and NTcpSocket.
virtual nint32 writeLine | ( | const NDataStream & | data, | |
nuint32 | bytes | |||
) | [pure virtual] |
Writes a line of data to the socket.
data | Data to be written to the socket | |
bytes | Max number of bytes to write to the socket |
Implemented in NTcpSocket, and NTcpSocket.
NHostAddress m_host [protected] |
Hostname
Definition at line 239 of file nabstractsocket.h.
Referenced by NTcpSocket::connectToHost(), NTcpSocket::execListen(), getHost(), NAbstractSocket(), NTcpSocket::read(), NTcpSocket::readLine(), setHost(), and NTcpSocket::waitForConnected().
Port
Definition at line 240 of file nabstractsocket.h.
Referenced by NTcpSocket::connectToHost(), NTcpSocket::execListen(), getPort(), NTcpSocket::setPort(), setPort(), and NTcpSocket::waitForConnected().
Time out, in seconds
Definition at line 242 of file nabstractsocket.h.
Referenced by getTimeout(), NTcpSocket::read(), NTcpSocket::readLine(), setTimeout(), and NTcpSocket::waitForConnected().
Socket options
Definition at line 243 of file nabstractsocket.h.
Referenced by NTcpSocket::setSocketOptions(), and setSocketOptions().
nint32 m_maxPendingConn [protected] |
Maximum number of pending connections
Definition at line 244 of file nabstractsocket.h.
Referenced by NTcpSocket::execListen(), getMaxPendingConnections(), and setMaxPendingConnections().