|
forb
|
C++ wrapper of the Socket POSIX API, which uses IPv4 and blocking communication. More...
#include <socket.hpp>
Public Member Functions | |
| socket ()=default | |
| Default constructor, creates an empty socket, which cannot be used to exchange data. | |
| ~socket () override | |
| Virtual destructor that closes the socket (if open). | |
| socket (const socket &other)=delete | |
| This class does not support copy construction. | |
| socket & | operator= (const socket &other)=delete |
| This class does not support copy assignment. | |
| socket (socket &&other) noexcept | |
| This class supports move construction. More... | |
| socket & | operator= (socket &&other) noexcept |
| This class supports move assignment. More... | |
| socket | accept () |
| Performs the accept operation on the given server socket. More... | |
| void | send (const void *buffer, std::size_t size) override |
| Blocking wrapper of the POSIX send function. More... | |
| void | recv (void *buffer, std::size_t size) override |
| Blocking wrapper of the POSIX recv function. More... | |
| void | close () noexcept override |
| Closes the socket, called by the virtual destructor. | |
| type | get_type () const override |
| Returns the type of the stream. | |
| bool | require_marshal () const override |
| Returns true if the execution platform requires marshalling before sending data on the socket, false otherwise. More... | |
Public Member Functions inherited from forb::streams::stream | |
| virtual | ~stream () noexcept=default |
| This class is virtual, so it requires a virtual destructor. More... | |
Static Public Member Functions | |
| static socket | make_server (int port, int listen_queue_size=10) |
| Creates a new server socket. More... | |
| static socket | make_server (const std::string &address, int port, int listen_queue_size=10) |
| Creates a new server socket. More... | |
| static socket | make_client (const std::string &address, int port) |
| Creates a new client socket, connected to the specified remote host. | |
Additional Inherited Members | |
Public Types inherited from forb::streams::stream | |
| enum | type : call_id_t { SOCKET = 0, SHMEM = 1 << (std::numeric_limits<call_id_t>::digits - 1) } |
| The type of the stream. More... | |
| using | size_t = std::size_t |
| An unsigned size type. | |
C++ wrapper of the Socket POSIX API, which uses IPv4 and blocking communication.
|
noexcept |
This class supports move construction.
The moved socket gets reset to the default values for each of its attributes.
| forb::streams::socket forb::streams::socket::accept | ( | ) |
Performs the accept operation on the given server socket.
Socket must be a server socket (i.e. a socket that executed a bind and a listen before).
|
inlinestatic |
Creates a new server socket.
The new server will be binded to any address on the local machine. The listen_queue_size argument is optional and defaulted to 10.
|
inlinestatic |
Creates a new server socket.
The new server will be binded to the address specified as argument, or to any address on the local machine if an empty string is given as argument. The listen_queue_size argument is optional and defaulted to 10.
|
noexcept |
This class supports move assignment.
The moved socket gets reset to the default values for each of its attributes.
|
overridevirtual |
Blocking wrapper of the POSIX recv function.
It repeats the underlying call until all data are received or an error occurs.
Implements forb::streams::stream.
|
inlineoverridevirtual |
Returns true if the execution platform requires marshalling before sending data on the socket, false otherwise.
Sending over a network requires marshalling (byteswapping) if the machine is not big endian.
Reimplemented from forb::streams::stream.
|
overridevirtual |
Blocking wrapper of the POSIX send function.
It repeats the underlying call until all data are sent or an error occurs.
Implements forb::streams::stream.
1.8.12