18 Sockets [socket]

18.4 Class socket_base [socket.base]

namespace std {
namespace experimental {
namespace net {
inline namespace v1 {

  class socket_base
  {
  public:
    class broadcast;
    class debug;
    class do_not_route;
    class keep_alive;
    class linger;
    class out_of_band_inline;
    class receive_buffer_size;
    class receive_low_watermark;
    class reuse_address;
    class send_buffer_size;
    class send_low_watermark;

    using shutdown_type = T1;
    static constexpr shutdown_type shutdown_receive;
    static constexpr shutdown_type shutdown_send;
    static constexpr shutdown_type shutdown_both;

    using wait_type = T2;
    static constexpr wait_type wait_read;
    static constexpr wait_type wait_write;
    static constexpr wait_type wait_error;

    using message_flags = T3;
    static constexpr message_flags message_peek;
    static constexpr message_flags message_out_of_band;
    static constexpr message_flags message_do_not_route;

    static const int max_listen_connections;

  protected:
    socket_base();
    ~socket_base();
  };

} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std

socket_base defines several member types:

  • socket option classes broadcast, debug, do_not_route, keep_alive, linger, out_of_band_inline, receive_buffer_size, receive_low_watermark, reuse_address, send_buffer_size, and send_low_watermark;

  • an enumerated type, shutdown_type, for use with the basic_socket<Protocol> class's shutdown member function.

  • an enumerated type, wait_type, for use with the basic_socket<Protocol> and basic_socket_acceptor<Protocol> classes' wait and async_wait member functions,

  • a bitmask type, message_flags, for use with the basic_stream_socket<Protocol> class's send, async_send, receive, and async_receive member functions, and the basic_datagram_socket<Protocol> class's send, async_send, send_to, async_send_to, receive, async_receive, receive_from, and async_receive_from member functions.

  • a constant, max_listen_connections, for use with the basic_socket_acceptor<Protocol> class's listen member function.

Table 33socket_base constants
Constant NamePOSIX macroDefinition or notes
shutdown_receive SHUT_RD Disables further receive operations.
shutdown_send SHUT_WR Disables further send operations.
shutdown_both SHUT_RDWR Disables further send and receive operations.
wait_read Wait until the socket is ready-to-read. For a given socket, when a wait or async_wait operation using wait_read completes successfully, a subsequent call to the socket's receive or receive_from functions may complete without blocking. Similarly, for a given acceptor, when a wait or async_wait operation using wait_read completes successfully, a subsequent call to the acceptor's accept function may complete without blocking.
wait_write Wait until the socket is ready-to-write. For a given socket, when a wait or async_wait operation using wait_write completes successfully, a subsequent call to the socket's send or send_to functions may complete without blocking.
wait_error Wait until the socket has a pending error condition. For a given socket, when a wait or async_wait operation using wait_error completes successfully, a subsequent call to one of the socket's synchronous operations may complete without blocking. The nature of the pending error condition determines which.
message_peek MSG_PEEK Leave received data in queue.
message_out_of_band MSG_OOB Out-of-band data.
message_do_not_route MSG_DONTROUTE Send without using routing tables.
max_listen_connections SOMAXCONN The implementation-defined limit on the length of the queue of pending incoming connections.