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

Public Types | |
| enum | Mode { Blocking , NonBlocking } |
| socket modes. More... | |
| enum | State { Connecting , Connected , Disconnecting , Disconnected , Closed } |
| socket states. More... | |
| using | Ptr = std::unique_ptr<BasicSocket<Protocol>> |
| using | Endpoint = typename Protocol::Endpoint |
| using | TimePoint = std::chrono::steady_clock::time_point |
Public Member Functions | |
| BasicSocket () noexcept | |
| default constructor. | |
| BasicSocket (Mode mode) noexcept | |
| 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) noexcept | |
| move constructor. | |
| BasicSocket & | operator= (BasicSocket &&other) noexcept |
| move assignment operator. | |
| virtual | ~BasicSocket () |
| destroy the socket instance. | |
| virtual int | open (const Protocol &protocol=Protocol()) noexcept |
| open socket using the given protocol. | |
| virtual void | close () noexcept |
| close the socket. | |
| virtual int | bind (const Endpoint &endpoint) noexcept |
| assigns the specified endpoint to the socket. | |
| bool | waitReadyRead () const noexcept |
| block until new data is available for reading. | |
| bool | waitReadyRead (std::chrono::nanoseconds timeout) const noexcept |
| block until new data is available for reading, giving up after the given duration. | |
| bool | waitReadyRead (TimePoint deadline) const noexcept |
| block until new data is available for reading, giving up at the given time point. | |
| bool | waitReadyWrite () const noexcept |
| block until at least one byte can be written. | |
| bool | waitReadyWrite (std::chrono::nanoseconds timeout) const noexcept |
| block until at least one byte can be written, giving up after the given duration. | |
| bool | waitReadyWrite (TimePoint deadline) const noexcept |
| block until at least one byte can be written, giving up at the given time point. | |
| void | setMode (Mode mode) noexcept |
| set the socket to the non-blocking or blocking mode. | |
| Endpoint | localEndpoint () const noexcept |
| determine the local endpoint associated with this socket. | |
| bool | opened () const noexcept |
| check if the socket is opened. | |
| int | family () const noexcept |
| get socket address family. | |
| int | type () const noexcept |
| get the protocol communication semantic. | |
| int | protocol () const noexcept |
| get socket protocol. | |
| Mode | mode () const noexcept |
| get the blocking mode of the socket. | |
| int | handle () const noexcept |
| get socket native handle. | |
| int | wait (bool wantRead, bool wantWrite) const noexcept |
| wait for the socket handle to become ready. | |
| int | waitFor (bool wantRead, bool wantWrite, std::chrono::nanoseconds timeout) const noexcept |
| wait for the socket handle to become ready, giving up after the given duration. | |
| int | waitUntil (bool wantRead, bool wantWrite, TimePoint deadline) const noexcept |
| wait for the socket handle to become ready, giving up at the given time point. | |
Protected Attributes | |
| State | _state = State::Closed |
| socket state. | |
| Mode | _mode = Mode::NonBlocking |
| socket mode. | |
| int | _handle = -1 |
| socket handle. | |
| Protocol | _protocol |
| protocol. | |
Friends | |
| template<class P , class E , size_t N> | |
| class | BasicAsyncRawSocket |
| friendship with basic asynchronous raw socket | |
basic socket class.
| using join::BasicSocket< Protocol >::Endpoint = typename Protocol::Endpoint |
| using join::BasicSocket< Protocol >::Ptr = std::unique_ptr<BasicSocket<Protocol>> |
| using join::BasicSocket< Protocol >::TimePoint = std::chrono::steady_clock::time_point |
| enum join::BasicSocket::Mode |
| enum join::BasicSocket::State |
|
inlinenoexcept |
default constructor.
|
inlineexplicitnoexcept |
create socket instance specifying the mode.
| mode | blocking mode. |
|
delete |
copy constructor.
| other | other object to copy. |
|
inlinenoexcept |
move constructor.
| other | other object to move. |
|
inlinevirtual |
destroy the socket instance.
|
inlinevirtualnoexcept |
assigns the specified endpoint to the socket.
| endpoint | endpoint to assign to the socket. |
Reimplemented in join::BasicRawSocket< Protocol >, join::BasicRawSocket< Netlink >, and join::BasicRawSocket< Raw >.
|
inlinevirtualnoexcept |
close the socket.
Reimplemented in join::BasicDatagramSocket< Protocol >, join::BasicDatagramSocket< Netlink >, and join::BasicStreamSocket< Protocol >.
|
inlinenoexcept |
get socket address family.
|
inlinenoexcept |
get socket native handle.
|
inlinenoexcept |
determine the local endpoint associated with this socket.
|
inlinenoexcept |
get the blocking mode of the socket.
|
inlinevirtualnoexcept |
open socket using the given protocol.
| protocol | protocol to use. |
Reimplemented in join::BasicDatagramSocket< Protocol >, and join::BasicDatagramSocket< Netlink >.
|
inlinenoexcept |
check if the socket is opened.
|
inlinenoexcept |
move assignment operator.
| other | other object to assign. |
|
delete |
copy assignment operator.
| other | other object to assign. |
|
inlinenoexcept |
get socket protocol.
|
inlinenoexcept |
set the socket to the non-blocking or blocking mode.
| mode | blocking mode. |
|
inlinenoexcept |
get the protocol communication semantic.
|
inlinenoexcept |
wait for the socket handle to become ready.
| wantRead | set to true if want read |
| wantWrite | set to true if want write. |
|
inlinenoexcept |
wait for the socket handle to become ready, giving up after the given duration.
| wantRead | set to true if want read |
| wantWrite | set to true if want write. |
| timeout | maximum time to wait. |
|
inlinenoexcept |
block until new data is available for reading.
|
inlinenoexcept |
block until new data is available for reading, giving up after the given duration.
| timeout | maximum time to wait. |
|
inlinenoexcept |
block until new data is available for reading, giving up at the given time point.
| deadline | time point at which to give up, max to wait indefinitely. |
|
inlinenoexcept |
block until at least one byte can be written.
|
inlinenoexcept |
block until at least one byte can be written, giving up after the given duration.
| timeout | maximum time to wait. |
|
inlinenoexcept |
block until at least one byte can be written, giving up at the given time point.
| deadline | time point at which to give up, max to wait indefinitely. |
|
inlinenoexcept |
wait for the socket handle to become ready, giving up at the given time point.
| wantRead | set to true if want read |
| wantWrite | set to true if want write. |
| deadline | time point at which to give up, max to wait indefinitely. |
|
friend |
friendship with basic asynchronous raw socket
|
protected |
socket handle.
|
protected |
socket mode.
|
protected |
protocol.
|
protected |
socket state.