General TCP socket interface.
More...
#include <tcpsocket.h>
List of all members.
Public Member Functions |
| NetworkLayerProtocol | getProtocol () const |
| | Returns the underlying network layer protocol which is used.
|
| virtual bool | create (uint16_t portNumber=0)=0 |
| | Creates a TCP socket.
|
| virtual bool | create (const NetworkLayerAddress &bindAddress, uint16_t portNumber=0)=0 |
| | Creates a TCP socket.
|
| virtual bool | destroy ()=0 |
| | Destroys the socket.
|
| virtual bool | setNonBlocking (bool f=true)=0 |
| | Can be used to set the socket to either non-blocking or blocking mode.
|
| virtual uint16_t | getLocalPortNumber ()=0 |
| | Returns the port number to which the socket is bound.
|
| virtual bool | connect (const NetworkLayerAddress &hostAddress, uint16_t portNumber)=0 |
| | Try to establish a TCP connection with a specified end-point.
|
| virtual bool | listen (int backlog)=0 |
| | Puts the socket in listen mode.
|
| virtual bool | accept (TCPSocket **pNewSock)=0 |
| | Accepts an incoming connection request.
|
| virtual bool | isConnected ()=0 |
| | Returns true if a TCP connection has been established.
|
| virtual const NetworkLayerAddress * | getDestinationAddress () const =0 |
| virtual uint16_t | getDestinationPort () const =0 |
| | Returns the port number of the other end of the TCP connection.
|
| virtual bool | write (const void *pData, size_t &length)=0 |
| | Writes data over the TCP connection.
|
| virtual bool | getAvailableDataLength (size_t &length)=0 |
| | Stores the number of bytes which can be read from the connection in length.
|
| virtual bool | read (void *pBuffer, size_t &bufferSize)=0 |
| | Reads data from the TCP connection.
|
Detailed Description
Member Function Documentation
| virtual bool nut::TCPSocket::accept |
( |
TCPSocket ** |
pNewSock | ) |
[pure virtual] |
Accepts an incoming connection request.
- Parameters:
-
| pNewSock | Will contain a new socket which can be used for communication. |
| virtual bool nut::TCPSocket::connect |
( |
const NetworkLayerAddress & |
hostAddress, |
|
|
uint16_t |
portNumber |
|
) |
| [pure virtual] |
Try to establish a TCP connection with a specified end-point.
- Parameters:
-
| hostAddress | IP address of the end-point. |
| portNumber | Port number of the end-point. |
| virtual bool nut::TCPSocket::create |
( |
uint16_t |
portNumber = 0 | ) |
[pure virtual] |
Creates a TCP socket.
- Parameters:
-
| portNumber | If not zero, the socket will be bound to this port number. |
| virtual bool nut::TCPSocket::create |
( |
const NetworkLayerAddress & |
bindAddress, |
|
|
uint16_t |
portNumber = 0 |
|
) |
| [pure virtual] |
Creates a TCP socket.
- Parameters:
-
| bindAddress | The socket will be bound to this address. |
| portNumber | If not zero, the socket will be bound to this port number. |
| virtual bool nut::TCPSocket::destroy |
( |
| ) |
[pure virtual] |
| virtual bool nut::TCPSocket::getAvailableDataLength |
( |
size_t & |
length | ) |
[pure virtual] |
| virtual const NetworkLayerAddress* nut::TCPSocket::getDestinationAddress |
( |
| ) |
const [pure virtual] |
Returns the address of the other end of the TCP connection.
| virtual uint16_t nut::TCPSocket::getDestinationPort |
( |
| ) |
const [pure virtual] |
| virtual uint16_t nut::TCPSocket::getLocalPortNumber |
( |
| ) |
[pure virtual] |
| virtual bool nut::TCPSocket::isConnected |
( |
| ) |
[pure virtual] |
| virtual bool nut::TCPSocket::listen |
( |
int |
backlog | ) |
[pure virtual] |
Puts the socket in listen mode, so that incoming connections can be accepted.
- Parameters:
-
| backlog | The maximum length of the queue of pending connections. |
| virtual bool nut::TCPSocket::read |
( |
void * |
pBuffer, |
|
|
size_t & |
bufferSize |
|
) |
| [pure virtual] |
Reads data from the TCP connection.
- Parameters:
-
| pBuffer | Pointer to the buffer where the data can be stored. |
| bufferSize | Initially, this should contain the maximum amount of bytes which may be stored in pBuffer. When the function returns, the variable contains the actual number of bytes read. |
| virtual bool nut::TCPSocket::setNonBlocking |
( |
bool |
f = true | ) |
[pure virtual] |
| virtual bool nut::TCPSocket::write |
( |
const void * |
pData, |
|
|
size_t & |
length |
|
) |
| [pure virtual] |
Writes data over the TCP connection.
- Parameters:
-
| pData | Pointer to the data which should be transmitted. |
| length | Initially, this should contain the number of bytes which should be transmitted. When the function returns, the variable will contain the number of bytes which were actually transmitted. |
The documentation for this class was generated from the following file: