The Micro C++ Library
micxx::SocketAddress Class Reference

A SocketAddress represents an abstract and protocol unspecific Socket address. More...

#include <micxx.hxx>

Inherits micxx::traits::ToString.

Inherited by micxx::InetAddress.

List of all members.

Public Member Functions

 SocketAddress (short afamily, socklen_t asize)
 Create a new SocketAddress for the specified address family.
 SocketAddress (const SocketAddress &right)
 Create a copy of SocketAddress right.
virtual ~SocketAddress ()
 Deallocate the stored struct sockaddr
virtual SocketAddressclone () const =0
 Create an exact copy of this SocketAddress allocated by new.
virtual struct sockaddr * getAddress ()
 A pointer to the stored struct sockaddr.
virtual struct sockaddr * getAddress () const
 The const version of getAddress().
virtual short getFamily () const
 The address family of this SocketAddress.
virtual socklen_t getSize () const
 The size of the store struct sockaddr.
virtual SocketAddressoperator= (const SocketAddress &right)
 Make this a copy of SocketAddress right.
virtual bool operator== (const SocketAddress &right) const
 Check, if this and right have the same address (content).
virtual bool operator!= (const SocketAddress &right) const
 Check, if this and right have a different address.
virtual void setAddress (const struct sockaddr *address, socklen_t size)
 (Re)set the stored address to address with size size.
virtual void setFamily (short family)
 (Re)set the address' family to family.
virtual std::string toString () const
 A string representation describing this SocketAddress.

Detailed Description

A SocketAddress represents an abstract and protocol unspecific Socket address.

Author:
Norbert Klose
Date:
December, 2006

Constructor & Destructor Documentation

micxx::SocketAddress::SocketAddress ( short  afamily,
socklen_t  asize 
)

Create a new SocketAddress for the specified address family.

Parameters:
afamilyThe address family, e.g. AF_INET in case of Internet Protocol (IP) addresses.
asizeThe size of the address structure, e.g. sizeof(struct sockaddr_in) in case of Internet Protocol (IP) addresses. If asize is greater than 0, a struct sockaddr is allocated to be able to receive an address with the specified size.
micxx::SocketAddress::SocketAddress ( const SocketAddress right)

Create a copy of SocketAddress right.

Parameters:
rightThe SocketAddress to copy from.
virtual micxx::SocketAddress::~SocketAddress ( ) [virtual]

Deallocate the stored struct sockaddr


Member Function Documentation

virtual SocketAddress* micxx::SocketAddress::clone ( ) const [pure virtual]

Create an exact copy of this SocketAddress allocated by new.

Returns:
An exact copy of this SocketAddress. The returned address is allocated with new. The calling application takes ownership of the allocated memory and it is in the responsibility of the calling application to delete the pointer when it is no more needed.

Implemented in micxx::InetAddress, and micxx::MulticastAddress.

virtual struct sockaddr* micxx::SocketAddress::getAddress ( ) [read, virtual]

A pointer to the stored struct sockaddr.

virtual struct sockaddr* micxx::SocketAddress::getAddress ( ) const [read, virtual]

The const version of getAddress().

virtual short micxx::SocketAddress::getFamily ( ) const [virtual]

The address family of this SocketAddress.

virtual socklen_t micxx::SocketAddress::getSize ( ) const [virtual]

The size of the store struct sockaddr.

virtual bool micxx::SocketAddress::operator!= ( const SocketAddress right) const [virtual]

Check, if this and right have a different address.

virtual SocketAddress& micxx::SocketAddress::operator= ( const SocketAddress right) [virtual]

Make this a copy of SocketAddress right.

Parameters:
rightTo SocketAddress to copy from.
Returns:
*this
virtual bool micxx::SocketAddress::operator== ( const SocketAddress right) const [virtual]

Check, if this and right have the same address (content).

virtual void micxx::SocketAddress::setAddress ( const struct sockaddr *  address,
socklen_t  size 
) [virtual]

(Re)set the stored address to address with size size.

If the old stored address was not 0, the old address is deleted before.

Reimplemented in micxx::InetAddress.

virtual void micxx::SocketAddress::setFamily ( short  family) [virtual]

(Re)set the address' family to family.

This setter must not be called, if the currently stored address is 0.

virtual std::string micxx::SocketAddress::toString ( ) const [virtual]

A string representation describing this SocketAddress.

Reimplemented from micxx::traits::ToString.

Reimplemented in micxx::InetAddress, and micxx::MulticastAddress.


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