| D++ (DPP) C++ Discord API Bot Library

Search
Loading...
Searching...
No Matches
dpp::raii_socket Struct Reference

Allocates a dpp::socket, closing it on destruction. More...

`#include <socket.h>`

Collaboration diagram for dpp::raii_socket:
[legend]

## Public Member Functions

| raii_socket (raii_socket &&)=delete
| Non-movable.
| raii_socket (raii_socket &)=delete
| Non-copyable.
| raii_socket (raii_socket_type type=rst_udp)
| Construct a socket. Calls socket() and returns a new file descriptor.
| raii_socket (socket plain_fd)
| Convert an established fd to an raii_socket.
| ~raii_socket ()
| Destructor Frees the socket by closing it.
socket | accept ()
| Accept a pending connection on listening socket.
bool | bind (address_t address)
| Bind socket to IP/port.
bool | listen ()
| Listen on previously bound port.
raii_socket | operator= (raii_socket &&)=delete
| Non-movable.
raii_socket | operator= (raii_socket &)=delete
| Non-copyable.
template<typename T>
bool | set_option (int level, int name, T value)
| Sets the value of a socket option.

## Public Attributes

socket | fd
| File descriptor.

## Detailed Description

Allocates a dpp::socket, closing it on destruction.

## Constructor & Destructor Documentation

## ◆ raii_socket() [1/4]

dpp::raii_socket::raii_socket | ( | raii_socket_type | type = rst_udp | ) |

Construct a socket. Calls socket() and returns a new file descriptor.

## ◆ raii_socket() [2/4]

dpp::raii_socket::raii_socket | ( | socket | plain_fd | ) |

Convert an established fd to an raii_socket.

Parameters

  plain_fd |

## ◆ raii_socket() [3/4]

dpp::raii_socket::raii_socket | ( | raii_socket & |  | ) |

delete

Non-copyable.

## ◆ raii_socket() [4/4]

dpp::raii_socket::raii_socket | ( | raii_socket && |  | ) |

delete

Non-movable.

## ◆ ~raii_socket()

dpp::raii_socket::~raii_socket | ( |  | ) |

Destructor Frees the socket by closing it.

## Member Function Documentation

## ◆ accept()

socket dpp::raii_socket::accept | ( |  | ) |

Accept a pending connection on listening socket.

Returns
  new connection file descriptor

## ◆ bind()

bool dpp::raii_socket::bind | ( | address_t | address | ) |

Bind socket to IP/port.

Parameters

  address | address to bind to

Returns
  true on success

## ◆ listen()

bool dpp::raii_socket::listen | ( |  | ) |

Listen on previously bound port.

Returns
  true on success

## ◆ operator=() [1/2]

raii_socket dpp::raii_socket::operator= | ( | raii_socket && |  | ) |

delete

Non-movable.

## ◆ operator=() [2/2]

raii_socket dpp::raii_socket::operator= | ( | raii_socket & |  | ) |

delete

Non-copyable.

## ◆ set_option()

template<typename T>

template DPP_EXPORT bool dpp::raii_socket::set_option< int > | ( | int | level,
|  | int | name,
|  | T | value )

Sets the value of a socket option.

Template Parameters

  T | type to set option for

Parameters

  level | The level at which to change the socket options
  name | The option to change the value of
  value | The value to set

Returns
  True if set successfully

## Member Data Documentation

## ◆ fd

socket dpp::raii_socket::fd

File descriptor.

D++ Library version 9.0.13 D++ Library version 9.0.12 D++ Library version 9.0.11 D++ Library version 9.0.10 D++ Library version 9.0.9 D++ Library version 9.0.8 D++ Library version 9.0.7 D++ Library version 9.0.6 D++ Library version 9.0.5 D++ Library version 9.0.4 D++ Library version 9.0.3 D++ Library version 9.0.2 D++ Library version 9.0.1 D++ Library version 9.0.0 D++ Library version 1.0.2 D++ Library version 1.0.1 D++ Library version 1.0.0