Source: unixaddress.h


Annotated List
Files
Globals
Hierarchy
Index
// ##########################################################################
// ####                                                                  ####
// ####                      RTP Audio Server Project                    ####
// ####                    ============================                  ####
// ####                                                                  ####
// #### Unix Address                                                     ####
// ####                                                                  ####
// #### Version 1.00  --  February 23, 2001                              ####
// ####                                                                  ####
// #### Copyright (C) 1999  Thomas Dreibholz                             ####
// ####               2000  Universität Bonn, Abt. IV                    ####
// ####               2001  EMail: Dreibholz@bigfoot.com                 ####
// ####                     WWW:   http://www.bigfoot.com/~dreibholz     ####
// ####                                                                  ####
// ##########################################################################


#ifndef UNIXADDRESS_H
#define UNIXADDRESS_H


#include "system.h"
#include "strings.h"
#include "socketaddress.h"
#include "portableaddress.h"


#include <sys/socket.h>
#include <sys/un.h>


namespace Coral {


/**
  * This class manages an unix socket address.
  *
  * @short   Socket Address
  * @author  Thomas Dreibholz (Dreibholz@bigfoot.com)
  * @version 1.0
  */            
class UnixAddress : virtual public SocketAddress
{
   // ====== Constructors/Destructor ========================================
   public:
   /**
     * Constructor for an empty unix address.
     */
   UnixAddress();

   /**
     * Constructor for an unix address from an unix address.
     *
     * @param address Unix address.
     */
   UnixAddress(const UnixAddress& address);

   /**
     * Constructor for a unix address given by a string.
     * Examples: "/tmp/test.socket".
     *
     * @param name Address string.
     */
   UnixAddress(const char* name);

   /**
     * Constructor for a unix address from the system's sockaddr structure.
     *
     * @param address sockaddr.
     * @param length Length of sockaddr.
     */
   UnixAddress(sockaddr* address, cardinal length);

   /**
     * Destructor.
     */
   ~UnixAddress();


   // ====== Initialization =================================================
   /**
     * Reset unix address.
     */
   void reset();

   /**
     * Initialize unix address from unix address.
     */
   void init(const UnixAddress& address);

   /**
     * Initialize unix address from socket name.
     */
   void init(const char* name);

   /**
     * Implementation of = operator.
     */
   inline UnixAddress& operator=(const UnixAddress& source);

   
   // ====== Address functions ==============================================
   /**
     * isValid() implementation of SocketAddress.
     *
     * @see SocketAddress#isValid
     */
   bool isValid() const;

   /**
     * Check, if the address is null.
     *
     * @return true, if the address is not null; false otherwise.
     */
   inline bool isNull() const;

   /**
     * Get address string.
     *
     * @return Address string.
     */
   String getAddressString() const;

   
   // ====== Get/set system sockaddr structure ==============================
   /**
     * getSystemAddress() implementation of SocketAddress
     *
     * @see SocketAddress#getSystemAddress
     */            
   cardinal getSystemAddress(sockaddr*      buffer,
                             const cardinal length,
                             const cardinal type) const;

   /**
     * setSystemAddress() implementation of SocketAddress.
     *
     * @see SocketAddress#setSystemAddress
     */
   bool setSystemAddress(sockaddr* address, const cardinal length);


    // ====== Comparision operators =========================================
   /**
     * Implementation of == operator.
     */
   int operator==(const UnixAddress& address) const;

   /**
     * Implementation of != operator.
     */
   inline int operator!=(const UnixAddress& address) const;

   /**
     * Implementation of < operator.
     */
   int operator<(const UnixAddress& address) const;

   /**
     * Implementation of <= operator.
     */
   inline int operator<=(const UnixAddress& address) const;

   /**
     * Implementation of > operator.
     */
   int operator>(const UnixAddress& address) const;

   /**
     * Implementation of >= operator.
     */
   inline int operator>=(const UnixAddress& address) const;


   // ====== Private data ===================================================
   private:
   static const cardinal MaxNameLength = 108;

   char Name[MaxNameLength];
};


}


#include "unixaddress.icc"


#endif

Generated by: viper@odin on Fri Feb 23 12:41:26 2001, using kdoc 2.0a36.