claw::socket_traits_unix Class Reference

Unix interface for using sockets. More...

`#include <socket_traits_unix.hpp>`

## Public Types

typedef int | descriptor
| Type of the system description of the socket.

## Static Public Member Functions

static bool | init ()
| Initialize the use of the socket library. More...
static bool | release ()
| Close the socket library. More...
static descriptor | open ()
| Open a socket. More...
static bool | close (descriptor d)
| Close a socket. More...
static bool | connect (descriptor d, const std::string &address, int port)
| Connect a socket to a port. More...
static bool | listen (descriptor d, int port, unsigned int queue_size)
| Open a socket for incoming connexions. More...
static bool | select_read (descriptor d, int time_limit=-1)
| Select a socket for reading. More...
static descriptor | accept (descriptor d)
| Accept an incoming connexion. More...
static bool | valid_descriptor (descriptor d)
| Tell if a descriptor is a valid socket descriptor. More...
static bool | is_open (descriptor d)
| Tell if a descriptor is a opened socket. More...

## Static Public Attributes

static const descriptor | invalid_socket = -1
| Invalid socket descriptor.

## Detailed Description

Unix interface for using sockets.

Author
  Julien Jorge

Definition at line 50 of file socket_traits_unix.hpp.

## Member Function Documentation

## accept()

static descriptor claw::socket_traits_unix::accept | ( | descriptor | d | ) |

inline static

Accept an incoming connexion.

Parameters

  d | The descriptor of the socket to listen.

Returns
  The descriptor of the incoming connexion.

Definition at line 202 of file socket_traits_unix.hpp.

## close()

static bool claw::socket_traits_unix::close | ( | descriptor | d | ) |

inline static

Close a socket.

Parameters

  d | The descriptor of the socket to close.

Returns
  true if the socket has been closed.

Definition at line 101 of file socket_traits_unix.hpp.

Referenced by claw::net::basic_socket::close().

## connect()

static bool claw::socket_traits_unix::connect | ( | descriptor | d,
|  | const std::string & | address,
|  | int | port
| ) |  |

inline static

Connect a socket to a port.

Parameters

  d | The descriptor of the socket to connect.
  address | The adress to connect to.
  port | The port to connect to.

Returns
  true if the connection is available.

Definition at line 114 of file socket_traits_unix.hpp.

References CLAW_PRECOND.

## init()

static bool claw::socket_traits_unix::init | ( |  | ) |

inline static

Initialize the use of the socket library.

Returns
  true if the initialization is successful.

Definition at line 66 of file socket_traits_unix.hpp.

Referenced by claw::net::socket_server::init().

## is_open()

static bool claw::socket_traits_unix::is_open | ( | descriptor | d | ) |

inline static

Tell if a descriptor is a opened socket.

Parameters

  d | The descriptor to test.

Definition at line 222 of file socket_traits_unix.hpp.

## listen()

static bool claw::socket_traits_unix::listen | ( | descriptor | d,
|  | int | port,
|  | unsigned int | queue_size
| ) |  |

inline static

Open a socket for incoming connexions.

Parameters

  d | The descriptor of the socket to open.
  port | The port to connect to.
  queue_size | The size of the queue for incoming connexions.

Returns
  true if the socket has been opened.

Definition at line 145 of file socket_traits_unix.hpp.

References CLAW_PRECOND.

Referenced by claw::net::socket_server::open().

## open()

static descriptor claw::socket_traits_unix::open | ( |  | ) |

inline static

Open a socket.

Returns
  The descriptor on the loaded socket.

Definition at line 86 of file socket_traits_unix.hpp.

References invalid_socket.

Referenced by claw::net::basic_socket::open().

## release()

static bool claw::socket_traits_unix::release | ( |  | ) |

inline static

Close the socket library.

Returns
  true if the operation is successful.

Definition at line 76 of file socket_traits_unix.hpp.

Referenced by claw::net::socket_server::release().

## select_read()

static bool claw::socket_traits_unix::select_read | ( | descriptor | d,
|  | int | time_limit = `-1`
| ) |  |

inline static

Select a socket for reading.

Parameters

  d | The descriptor of the socket to read.
  time_limit | Maximum of seconds to wait before considering there's nothing to read. If time_limit is negative, the method wait until there is something to read.

Returns
  true if the socket is ready to be read.

Definition at line 171 of file socket_traits_unix.hpp.

References CLAW_PRECOND.

## valid_descriptor()

static bool claw::socket_traits_unix::valid_descriptor | ( | descriptor | d | ) |

inline static

Tell if a descriptor is a valid socket descriptor.

Parameters

  d | The descriptor to test.

Definition at line 212 of file socket_traits_unix.hpp.

References invalid_socket.

Referenced by claw::net::basic_socket::is_open(), and claw::net::basic_socket::open().

The documentation for this class was generated from the following file:

- socket_traits_unix.hpp