.TH "FBB::InetAddress" "3bobcat" "2005\-2020" "libbobcat\-dev_5\&.07\&.00" "Network Byte Order" .PP .SH "NAME" FBB::InetAddress \- Converting between host byte order and network byte order .PP .SH "SYNOPSIS" \fB#include \fP .br Linking option: \fI\-lbobcat\fP .PP .SH "DESCRIPTION" Computers differ their word\-byte order, called `endianness\(cq\&\&. A little\-endian computer has its least significant byte at the byte having the lower address of a two\-byte value, whereas a big\-endian computer has its least significant byte at at the byte having the higher address of a two\-byte value\&. In order to allow these computers to communicate over over Internet, \fIhost byte order\fP was designed\&. Objects of the class \fBFBB::InetAddress\fP may be used to convert between network byte order and host byte order (and vice versa)\&. .PP The class only has a few public members\&. Most members are protected, and \fBFBB::InetAddress\fP is therefore primarily used as a base class from which other classes are derived\&. In practice there will be little need to construct objects of the class \fBFBB::InetAddress\fP, which is primarily a support class for the \fBFBB\fP socket\-classes\&. .PP Internally, all data are stored in network byte order\&. .PP As the class\(cq\& constructors depend on the proper functioning of members of the \fBFBB:GetHostent\fP class, the class\(cq\& objects can only be constructed when the host whose name or address is searched can be resolved by a name resolution process, e\&.g\&., \fBbind\fP(1)\&. .PP Objects of the class \fBFBB::InetAddress\fP store address information about a host in a \fBstruct sockaddr_in\fP data member\&. A \fBstruct sockaddr_in\fP is the data type used to represent socket addresses in the Internet namespace\&. It has the following members: .IP o \fBsa_family_t sin_family\fP: .br This identifies the address family or format of the socket address\&. It holds the value \fBAF_INET\fP\&. .IP o \fBstruct in_addr sin_addr\fP: .br This is the Internet address of the host machine stored as a binary value\&. .IP o \fBsize_t short int sin_port\fP: .br This field holds the port number\&. .PP .SH "NAMESPACE" \fBFBB\fP .br All constructors, members, operators and manipulators, mentioned in this man\-page, are defined in the namespace \fBFBB\fP\&. .PP .SH "INHERITS FROM" \- .PP .SH "PROTECTED CONSTRUCTORS" .IP o \fBInetAddress(std::string const &host, uint16_t port)\fP: .br This constructor expects a host name or dotted decimal address and and an (size_t) port number, and determines the host\(cq\&s address information\&. An \fBFBB::Exception\fP exception is thrown if the address could not be determined\&. .IP o \fBInetAddress(uint16_t port)\fP: .br This constructor constructs the `generic\(cq\& address information that is used when constructing, e\&.g\&. server sockets\&. .IP o \fBInetAddress(sockaddr_in const &address)\fP: .br This constructor constructs an \fBFBB::InetAddress\fP object from an initialized \fBsockaddr_in\fP object\&. It is primarily used to promote a \fBsockaddr_in\fP to an \fBFBB::InetAddresss\fP\&. .PP The (public) copy and move constructors (and assignment operators) are available\&. .PP .SH "MEMBER FUNCTIONS" .IP o \fBuint16_t port() const\fP: .br Accessor returning the object\(cq\&s port value\&. .IP o \fBstd::string dottedDecimalAddress() const\fP: .br Accessor returning the object\(cq\&s Internet address as a dotted decimal string\&. If the address could not be determined, an \fBFBB::Exception\fP object is thrown\&. .IP o \fBsize_t size() const\fP: .br Accessor returning the size of the object\(cq\&s \fBsockaddr_in\fP (address) information\&. .IP o \fBsockaddr const *sockaddrPtr() const\fP: .br Accessor returning the pointer to the object\(cq\&s \fBsockaddr\fP data member\&. .IP o \fBsockaddr_in const *sockaddr_inPtr() const\fP: .br Accessor returning the pointer to the object\(cq\&s \fBsockaddr_in\fP data member\&. .PP .SH "PROTECTED MEMBER FUNCTIONS" .IP o \fBsockaddr *sockaddrPtr()\fP: .br This member returns the object\(cq\&s address information as a pointer to a modifiable \fBstruct sockaddr\fP\&. This allows (contrary to the public member having the same name) derived objects to manipulate the object\(cq\&s address information directly\&. .IP o \fBsockaddr_in *sockaddr_inPtr()\fP: .br This member returns the object\(cq\&s address information as a pointer to a modifiable \fBstruct sockaddr_in\fP\&. This allows (contrary to the public member having the same name) derived objects to manipulate the object\(cq\&s address information directly\&. .PP .SH "EXAMPLE" .nf #include #include #include using namespace std; using namespace FBB; InetAddress X() { class A: public InetAddress { public: A(uint16_t port) : InetAddress(port) {} }; return A(2000); } int main(int argc, char **argv) try { InetAddress const &ia = X(); cout << \(dq\&A InetAddress was constructed for port \(dq\& << ia\&.port() << endl; cout << \(dq\&It has the generic `ANY\(cq\& address: \(dq\& << ia\&.dottedDecimalAddress() << endl; } catch (exception const &e) { cout << \(dq\&Exception: \(dq\& << e\&.what() << endl; } .fi .PP .SH "FILES" \fIbobcat/inetaddress\fP \- defines the class interface .PP .SH "SEE ALSO" \fBbind\fP(1), \fBbobcat\fP(7), \fBgethostent\fP(3bobcat), \fBsocketbase\fP(3bobcat) .PP .SH "BUGS" None Reported\&. .PP .SH "BOBCAT PROJECT FILES" .PP .IP o \fIhttps://fbb\-git\&.gitlab\&.io/bobcat/\fP: gitlab project page; .IP o \fIbobcat_5\&.07\&.00\-x\&.dsc\fP: detached signature; .IP o \fIbobcat_5\&.07\&.00\-x\&.tar\&.gz\fP: source archive; .IP o \fIbobcat_5\&.07\&.00\-x_i386\&.changes\fP: change log; .IP o \fIlibbobcat1_5\&.07\&.00\-x_*\&.deb\fP: debian package containing the libraries; .IP o \fIlibbobcat1\-dev_5\&.07\&.00\-x_*\&.deb\fP: debian package containing the libraries, headers and manual pages; .PP .SH "BOBCAT" Bobcat is an acronym of `Brokken\(cq\&s Own Base Classes And Templates\(cq\&\&. .PP .SH "COPYRIGHT" This is free software, distributed under the terms of the GNU General Public License (GPL)\&. .PP .SH "AUTHOR" Frank B\&. Brokken (\fBf\&.b\&.brokken@rug\&.nl\fP)\&. .PP