olsr::sys::UnixSocket Class Reference

Unix socket (SOCK_DGRAM only) implementation. More...

#include <unixsocket.hh>

List of all members.

Public Types

typedef struct::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 Thisdummy ()
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 = 0
static This _dummy
 a static dummy object


Detailed Description

Unix socket (SOCK_DGRAM only) implementation.

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.


Member Typedef Documentation

typedef struct ::sockaddr_un olsr::sys::UnixSocket::sockaddr_t [read]

socket address type (sockaddr structure)

typedef std::string olsr::sys::UnixSocket::path_t

type for filenames


Member Enumeration Documentation

Enumerator:
_dummy_val 


Constructor & Destructor Documentation

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

References init().

olsr::sys::UnixSocket::UnixSocket ( const path_t fname  )  [inline]

The normal constructor

  • fname filename to bind to

References bind(), and init().

olsr::sys::UnixSocket::~UnixSocket (  )  [inline, virtual]


Member Function Documentation

void olsr::sys::UnixSocket::bind ( const path_t fname  )  [inline]

bind primitive

  • fname the filename to bind to

References _bound, _fd, and UNIX_PATH_MAX.

Referenced by UnixSocket().

void olsr::sys::UnixSocket::listen (  )  [inline]

References _fd, and UNIX_BACKLOG.

void olsr::sys::UnixSocket::connect ( const path_t fname  )  [inline]

connect primitive

  • fname the filename to connect to

References _fd, and UNIX_PATH_MAX.

UnixSocket olsr::sys::UnixSocket::accept ( path_t fname  )  [inline]

References _fd.

void olsr::sys::UnixSocket::close (  )  [inline]

References _bound, _fd, and _locked.

utl::Data olsr::sys::UnixSocket::receive (  )  const [inline]

receive primitive, receives a packet

  • sender returned parameter : source address (filename)
    Returns:
    all the data received

References _fd, olsr::utl::Data::raw(), olsr::utl::Data_< Self >::shrink_to(), olsr::utl::Data_< Self >::size(), and VIRTUAL_MTU.

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

  • d the data to send

References _fd, olsr::utl::Data_< Self >::raw(), and olsr::utl::Data_< Self >::size().

sch::IOEvent::p_t olsr::sys::UnixSocket::read_p (  )  const [inline]

References _fd.

sch::IOEvent::p_t olsr::sys::UnixSocket::write_p (  )  const [inline]

References _fd.

bool olsr::sys::UnixSocket::operator< ( const This rhs  )  const [inline]

comparating operator, needed for creating a socket set

  • rhs the other operand
    Returns:
    if rhs > this object

References _fd.

static const This& olsr::sys::UnixSocket::dummy (  )  [inline, static]

accessor to dummy static object

Returns:
a dummy socket

References _dummy.

static void olsr::sys::UnixSocket::lock (  )  [inline, static]

References _locked.

void olsr::sys::UnixSocket::init (  )  [inline, private]

Internal utility function used by constructors.

References _bound, and _fd.

Referenced by UnixSocket().


Member Data Documentation

the socket file descriptor

Referenced by accept(), bind(), close(), connect(), init(), listen(), operator<(), read_p(), receive(), send(), and write_p().

Referenced by bind(), close(), and init().

bool olsr::sys::UnixSocket::_locked = 0 [static, private]

Referenced by close(), and lock().

a static dummy object

Referenced by dummy().


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

Generated on Thu Feb 12 20:45:39 2009 for Qolyester daemon by  doxygen 1.5.6