|
join 1.0
lightweight network framework library
|
basic datagram socket class. More...
#include <socket.hpp>


Public Types | |
| using | Ptr = std::unique_ptr <BasicDatagramSocket <Protocol>> |
| using | Mode = typename BasicSocket <Protocol>::Mode |
| using | Option = typename BasicSocket <Protocol>::Option |
| using | State = typename BasicSocket <Protocol>::State |
| using | Endpoint = typename Protocol::Endpoint |
Public Types inherited from join::BasicSocket< Protocol > | |
| enum | Mode { Blocking , NonBlocking } |
| socket modes. More... | |
| enum | Option { NoDelay , KeepAlive , KeepIdle , KeepIntvl , KeepCount , SndBuffer , RcvBuffer , TimeStamp , ReuseAddr , ReusePort , Broadcast , Ttl , MulticastLoop , MulticastTtl , PathMtuDiscover , RcvError , AuxData } |
| socket options. More... | |
| enum | State { Connecting , Connected , Disconnecting , Disconnected , Closed } |
| socket states. More... | |
| using | Ptr = std::unique_ptr <BasicSocket <Protocol>> |
| using | Endpoint = typename Protocol::Endpoint |
Public Member Functions | |
| BasicDatagramSocket (int ttl=60) | |
| Default constructor. | |
| BasicDatagramSocket (Mode mode, int ttl=60) | |
| Create instance specifying the mode. | |
| BasicDatagramSocket (const BasicDatagramSocket &other)=delete | |
| Copy constructor. | |
| BasicDatagramSocket & | operator= (const BasicDatagramSocket &other)=delete |
| Copy assignment operator. | |
| BasicDatagramSocket (BasicDatagramSocket &&other) | |
| Move constructor. | |
| BasicDatagramSocket & | operator= (BasicDatagramSocket &&other) |
| Move assignment operator. | |
| virtual | ~BasicDatagramSocket ()=default |
| Destroy the instance. | |
| virtual int | open (const Protocol &protocol=Protocol()) noexcept override |
| open socket using the given protocol. | |
| virtual int | bindToDevice (const std::string &device) noexcept |
| assigns the specified device to the socket. | |
| virtual int | connect (const Endpoint &endpoint) |
| make a connection to the given endpoint. | |
| virtual int | disconnect () |
| shutdown the connection. | |
| virtual void | close () noexcept override |
| close the socket handle. | |
| virtual int | read (char *data, unsigned long maxSize) noexcept override |
| read data. | |
| virtual int | readFrom (char *data, unsigned long maxSize, Endpoint *endpoint=nullptr) noexcept |
| read data on the socket. | |
| virtual int | write (const char *data, unsigned long maxSize) noexcept override |
| write data. | |
| virtual int | writeTo (const char *data, unsigned long maxSize, const Endpoint &endpoint) noexcept |
| write data on the socket. | |
| virtual int | setOption (Option option, int value) noexcept override |
| set the given option to the given value. | |
| const Endpoint & | remoteEndpoint () const |
| determine the remote endpoint associated with this socket. | |
| virtual bool | connected () noexcept |
| check if the socket is connected. | |
| int | mtu () const |
| get socket mtu. | |
| int | ttl () const |
| returns the Time-To-Live value. | |
Public Member Functions inherited from join::BasicSocket< Protocol > | |
| BasicSocket () | |
| default constructor. | |
| BasicSocket (Mode mode) | |
| create socket instance specifying the mode. | |
| BasicSocket (const BasicSocket &other)=delete | |
| copy constructor. | |
| BasicSocket & | operator= (const BasicSocket &other)=delete |
| copy assignment operator. | |
| BasicSocket (BasicSocket &&other) | |
| move constructor. | |
| BasicSocket & | operator= (BasicSocket &&other) |
| move assignment operator. | |
| virtual | ~BasicSocket () |
| destroy the socket instance. | |
| virtual int | bind (const Endpoint &endpoint) noexcept |
| assigns the specified endpoint to the socket. | |
| virtual int | canRead () const noexcept |
| get the number of readable bytes. | |
| virtual bool | waitReadyRead (int timeout=0) const noexcept |
| block until new data is available for reading. | |
| virtual bool | waitReadyWrite (int timeout=0) const noexcept |
| block until at least one byte can be written. | |
| void | setMode (Mode mode) noexcept |
| set the socket to the non-blocking or blocking mode. | |
| Endpoint | localEndpoint () const |
| determine the local endpoint associated with this socket. | |
| bool | opened () const noexcept |
| check if the socket is opened. | |
| virtual bool | encrypted () const noexcept |
| check if the socket is secure. | |
| int | family () const noexcept |
| get socket address family. | |
| int | type () const noexcept |
| get the protocol communication semantic. | |
| int | protocol () const noexcept |
| get socket protocol. | |
| int | handle () const noexcept override |
| get socket native handle. | |
Public Member Functions inherited from join::EventHandler | |
| EventHandler ()=default | |
| create instance. | |
| virtual | ~EventHandler ()=default |
| destroy instance. | |
Protected Attributes | |
| Endpoint | _remote |
| remote endpoint. | |
| int | _ttl = 60 |
| packet time to live. | |
Protected Attributes inherited from join::BasicSocket< Protocol > | |
| State | _state = State::Closed |
| socket state. | |
| Mode | _mode = Mode::NonBlocking |
| socket mode. | |
| int | _handle = -1 |
| socket handle. | |
| Protocol | _protocol |
| protocol. | |
Additional Inherited Members | |
Static Public Member Functions inherited from join::BasicSocket< Protocol > | |
| static uint16_t | checksum (const uint16_t *data, size_t len, uint16_t current=0) |
| get standard 1s complement checksum. | |
Protected Member Functions inherited from join::BasicSocket< Protocol > | |
| int | wait (bool wantRead, bool wantWrite, int timeout) const noexcept |
| wait for the socket handle to become ready. | |
Protected Member Functions inherited from join::EventHandler | |
| virtual void | onReceive () |
| method called when data are ready to be read on handle. | |
| virtual void | onClose () |
| method called when handle is closed. | |
| virtual void | onError () |
| method called when an error occured on handle. | |
basic datagram socket class.
| using join::BasicDatagramSocket< Protocol >::Endpoint = typename Protocol::Endpoint |
| using join::BasicDatagramSocket< Protocol >::Mode = typename BasicSocket <Protocol>::Mode |
| using join::BasicDatagramSocket< Protocol >::Option = typename BasicSocket <Protocol>::Option |
| using join::BasicDatagramSocket< Protocol >::Ptr = std::unique_ptr <BasicDatagramSocket <Protocol>> |
| using join::BasicDatagramSocket< Protocol >::State = typename BasicSocket <Protocol>::State |
|
inline |
Default constructor.
|
inline |
Create instance specifying the mode.
| mode | Set the socket blocking mode. |
|
delete |
Copy constructor.
| other | Other object to copy. |
|
inline |
Move constructor.
| other | Other object to move. |
|
virtualdefault |
Destroy the instance.
|
inlinevirtualnoexcept |
assigns the specified device to the socket.
| device | device name. |
|
inlineoverridevirtualnoexcept |
close the socket handle.
Reimplemented from join::BasicSocket< Protocol >.
Reimplemented in join::BasicTlsSocket< Protocol >.
|
inlinevirtual |
make a connection to the given endpoint.
| endpoint | endpoint to connect to. |
|
inlinevirtualnoexcept |
check if the socket is connected.
Reimplemented in join::BasicStreamSocket< Protocol >.
|
inlinevirtual |
shutdown the connection.
Reimplemented in join::BasicStreamSocket< Protocol >, and join::BasicTlsSocket< Protocol >.
|
inline |
get socket mtu.
|
inlineoverridevirtualnoexcept |
open socket using the given protocol.
| protocol | protocol to use. |
Reimplemented from join::BasicSocket< Protocol >.
|
inline |
Move assignment operator.
| other | other object to assign. |
|
delete |
Copy assignment operator.
| other | other object to assign. |
|
inlineoverridevirtualnoexcept |
read data.
| data | buffer used to store the data received. |
| maxSize | maximum number of bytes to read. |
Reimplemented from join::BasicSocket< Protocol >.
Reimplemented in join::BasicTlsSocket< Protocol >.
|
inlinevirtualnoexcept |
read data on the socket.
| data | buffer used to store the data received. |
| maxSize | maximum number of bytes to read. |
| endpoint | endpoint from where data are coming (optional). |
|
inline |
determine the remote endpoint associated with this socket.
|
inlineoverridevirtualnoexcept |
set the given option to the given value.
| option | socket option. |
| value | option value. |
Reimplemented from join::BasicSocket< Protocol >.
Reimplemented in join::BasicStreamSocket< Protocol >.
|
inline |
returns the Time-To-Live value.
|
inlineoverridevirtualnoexcept |
write data.
| data | data buffer to send. |
| maxSize | maximum number of bytes to write. |
Reimplemented from join::BasicSocket< Protocol >.
Reimplemented in join::BasicTlsSocket< Protocol >.
|
inlinevirtualnoexcept |
write data on the socket.
| data | data buffer to send. |
| maxSize | maximum number of bytes to write. |
| endpoint | endpoint where to write the data. |
|
protected |
remote endpoint.
|
protected |
packet time to live.