|
The Micro C++ Library
|
A Socket class could be bound to a SocketAddress and provides the interface to generic BSD socket API compliant Socket properties. More...
#include <micxx.hxx>
Inherits micxx::Mutex, and micxx::traits::Connection.
Inherited by micxx::DatagramSocket, micxx::ServerSocket, and micxx::StreamSocket.
Public Member Functions | |
| virtual | ~Socket () |
| Close the socket and delete the internal stored SocketAddress. | |
| virtual void | bind (const SocketAddress &socketAddress) |
| Bind this Socket to the specified SocketAddress socketAddress. | |
| virtual void | close (ClosingMode closingMode=BiDirectional) |
| Close this socket and release underlying system resources. | |
| virtual const SocketAddress * | getAddress () const |
| The stored SocketAddress. | |
| virtual std::size_t | getReceiveBufferSize () const |
The current value for socket option SO_RCVBUF of level SOL_SOCKET. | |
| virtual bool | getReuseAddress () const |
The current value for socket option SO_REUSEADDR of level SOL_SOCKET. | |
| virtual std::size_t | getSendBufferSize () const |
The current value for socket option SO_SNDBUF of level SOL_SOCKET. | |
| virtual int | getSocketType () const |
| The type of this Socket. | |
| virtual | operator socket_t () |
| The underlying socket descriptior. | |
| virtual void | setReceiveBufferSize (std::size_t value) |
Set the current value for socket option SO_RCVBUF of level SOL_SOCKET. | |
| virtual void | setReuseAddress (bool value) |
Set the current value for socket option SO_REUSEADDR of level SOL_SOCKET. | |
| virtual void | setSendBufferSize (std::size_t value) |
Set the current value for socket option SO_SNDBUF of level SOL_SOCKET. | |
| virtual std::string | toString () const |
| Returns a printable representation. | |
Static Public Member Functions | |
| static int | getLastSocketError () |
| Return the last system error that was set by a underlying socket API call. | |
Protected Member Functions | |
| Socket (int socketType) | |
| Create a socket of the specified type. | |
| Socket (int socketType, socket_t rawSocket, SocketAddress *socketAddress) | |
| Create a Socket to an already connected rawSocket socket descriptor bound to the specified socketAddress. | |
| virtual void | createSocket (int addressFamily) |
| Create the underlying socket descriptor for the specified addressFamily. | |
| virtual void | setAddress (const SocketAddress *socketAddress) |
| Set this Socket's SocketAddress to a copy of socketAddress. | |
Protected Attributes | |
| socket_t | socket |
| The underlying socket descriptor. | |
A Socket class could be bound to a SocketAddress and provides the interface to generic BSD socket API compliant Socket properties.
| virtual micxx::Socket::~Socket | ( | ) | [virtual] |
Close the socket and delete the internal stored SocketAddress.
| micxx::Socket::Socket | ( | int | socketType | ) | [protected] |
Create a socket of the specified type.
| socketType | Either SOCK_STREAM or SOCK_DGRAM. |
| micxx::Socket::Socket | ( | int | socketType, |
| socket_t | rawSocket, | ||
| SocketAddress * | socketAddress | ||
| ) | [protected] |
Create a Socket to an already connected rawSocket socket descriptor bound to the specified socketAddress.
| socketType | The type of the socket. |
| rawSocket | The socket descriptor. |
| socketAddress | The socket address to be used internally. This socket takes ownership of the allocated SocketAdress and gets responsible for deleting it. |
| virtual void micxx::Socket::bind | ( | const SocketAddress & | socketAddress | ) | [virtual] |
Bind this Socket to the specified SocketAddress socketAddress.
| socketAddress | A copy of socketAddress is stored internally. |
Reimplemented in micxx::ServerSocket.
| virtual void micxx::Socket::close | ( | ClosingMode | closingMode = BiDirectional | ) | [virtual] |
Close this socket and release underlying system resources.
Implements micxx::traits::Connection.
Reimplemented in micxx::SSLClientSocket, and micxx::StreamSocket.
| virtual void micxx::Socket::createSocket | ( | int | addressFamily | ) | [protected, virtual] |
Create the underlying socket descriptor for the specified addressFamily.
| addressFamily | The family of the stored SocketAddress. |
Reimplemented in micxx::DatagramSocket, micxx::MulticastSocket, and micxx::StreamSocket.
| virtual const SocketAddress* micxx::Socket::getAddress | ( | ) | const [virtual] |
The stored SocketAddress.
0, if no SocketAddress has been set so far. | static int micxx::Socket::getLastSocketError | ( | ) | [static] |
Return the last system error that was set by a underlying socket API call.
WSAGetLastError() is returned. Otheriwse it simply returns errno. | virtual std::size_t micxx::Socket::getReceiveBufferSize | ( | ) | const [virtual] |
The current value for socket option SO_RCVBUF of level SOL_SOCKET.
| virtual bool micxx::Socket::getReuseAddress | ( | ) | const [virtual] |
The current value for socket option SO_REUSEADDR of level SOL_SOCKET.
| virtual std::size_t micxx::Socket::getSendBufferSize | ( | ) | const [virtual] |
The current value for socket option SO_SNDBUF of level SOL_SOCKET.
| virtual int micxx::Socket::getSocketType | ( | ) | const [virtual] |
The type of this Socket.
SOCK_STREAM or SOCK_DGRAM | virtual micxx::Socket::operator socket_t | ( | ) | [virtual] |
The underlying socket descriptior.
| virtual void micxx::Socket::setAddress | ( | const SocketAddress * | socketAddress | ) | [protected, virtual] |
Set this Socket's SocketAddress to a copy of socketAddress.
| socketAddress | the new SocketAddress to be set. A copy of socketAddress will be set. If socketAddress is 0 and the stored SocketAddress is set already, only this SocketAddress is deleted and reset to 0. |
If this Socket has already a SocketAddress set, this is deleted before.
| virtual void micxx::Socket::setReceiveBufferSize | ( | std::size_t | value | ) | [virtual] |
Set the current value for socket option SO_RCVBUF of level SOL_SOCKET.
| virtual void micxx::Socket::setReuseAddress | ( | bool | value | ) | [virtual] |
Set the current value for socket option SO_REUSEADDR of level SOL_SOCKET.
| virtual void micxx::Socket::setSendBufferSize | ( | std::size_t | value | ) | [virtual] |
Set the current value for socket option SO_SNDBUF of level SOL_SOCKET.
| virtual std::string micxx::Socket::toString | ( | ) | const [virtual] |
Returns a printable representation.
Reimplemented from micxx::Mutex.
Reimplemented in micxx::ServerSocket, and micxx::StreamSocket.
socket_t micxx::Socket::socket [protected] |
The underlying socket descriptor.