#include <unixsocket.hh>
Public Types | |
typedef ::sockaddr_un | sockaddr_t |
typedef std::string | path_t |
Public Member Functions | |
UnixSocket () | |
UnixSocket (const path_t &fname) | |
virtual | ~UnixSocket () |
void | bind (const path_t &fname) |
void | listen () |
void | connect (const path_t &fname) |
This | accept (path_t &fname) |
void | close () |
utl::Data | receive () const |
bool | send (const utl::ConstData &d, int flags=0) const |
sch::IOEvent::p_t | read_p () const |
sch::IOEvent::p_t | write_p () const |
bool | operator< (const This &rhs) const |
Static Public Member Functions | |
static const This & | dummy () |
static void | lock () |
Private Types | |
enum | _dummy_values { _dummy_val } |
typedef UnixSocket | This |
Private Member Functions | |
UnixSocket (_dummy_values) | |
UnixSocket (int fd) | |
void | init () |
Private Attributes | |
int | _fd |
the socket file descriptor | |
bool | _bound |
Static Private Attributes | |
static bool | _locked |
static This | _dummy |
a static dummy object |
Here's an high-level implementation of unix sockets, for Qolyester's needs; only UDP is allowed (SOCK_DGRAM), and some special socket options may be not available. Anyway, migrating to TCP sockets is a piece of cake (c) : all TCP-only primitives are already here.
typedef UnixSocket olsr::sys::UnixSocket::This [private] |
typedef struct ::sockaddr_un olsr::sys::UnixSocket::sockaddr_t |
socket address type (sockaddr structure)
typedef std::string olsr::sys::UnixSocket::path_t |
type for filenames
enum olsr::sys::UnixSocket::_dummy_values [private] |
olsr::sys::UnixSocket::UnixSocket | ( | _dummy_values | ) | [private] |
A dummy constructor for a dummy static object
olsr::sys::UnixSocket::UnixSocket | ( | int | fd | ) | [inline, explicit, private] |
olsr::sys::UnixSocket::UnixSocket | ( | ) | [inline] |
The default constructor, opens only a socket
olsr::sys::UnixSocket::UnixSocket | ( | const path_t & | fname | ) | [inline] |
The normal constructor
olsr::sys::UnixSocket::~UnixSocket | ( | ) | [inline, virtual] |
void olsr::sys::UnixSocket::bind | ( | const path_t & | fname | ) | [inline] |
bind primitive
void olsr::sys::UnixSocket::listen | ( | ) | [inline] |
void olsr::sys::UnixSocket::connect | ( | const path_t & | fname | ) | [inline] |
connect primitive
UnixSocket olsr::sys::UnixSocket::accept | ( | path_t & | fname | ) | [inline] |
void olsr::sys::UnixSocket::close | ( | ) | [inline] |
utl::Data olsr::sys::UnixSocket::receive | ( | ) | const [inline] |
receive primitive, receives a packet
bool olsr::sys::UnixSocket::send | ( | const utl::ConstData & | d, | |
int | flags = 0 | |||
) | const [inline] |
send primitive, sends a packet, deprected because of using SOCK_DGRAM
sch::IOEvent::p_t olsr::sys::UnixSocket::read_p | ( | ) | const [inline] |
sch::IOEvent::p_t olsr::sys::UnixSocket::write_p | ( | ) | const [inline] |
bool olsr::sys::UnixSocket::operator< | ( | const This & | rhs | ) | const [inline] |
comparating operator, needed for creating a socket set
static const This& olsr::sys::UnixSocket::dummy | ( | ) | [inline, static] |
accessor to dummy static object
static void olsr::sys::UnixSocket::lock | ( | ) | [inline, static] |
void olsr::sys::UnixSocket::init | ( | ) | [inline, private] |
Internal utility function used by constructors.
int olsr::sys::UnixSocket::_fd [private] |
the socket file descriptor
bool olsr::sys::UnixSocket::_bound [private] |
bool olsr::sys::UnixSocket::_locked [static, private] |
This olsr::sys::UnixSocket::_dummy [static, private] |
a static dummy object