The Be Book The Network Kit The Network Kit Index

BNetAddress

Derived from: BArchivable
Declared in:  be/net/NetAddress.h
Library: libnetapi.so
Allocation: Constructor only
Summary:  more...


The BNetAddress class is used to construct and represent network addresses, providing access to them in a variety of formats. Additional functions are available to convert addresses from one format into another.


Constructor and Destructor


BNetAddress()

BNetAddress(const char *hostname = NULL, unsigned short port = 0)
BNetAddress(const sockaddr_in &sa)
BNetAddress(in_addr addr, int port = 0)
BNetAddress(uint32 addr, int port = 0)
BNetAddress(const char *hostname, const char *protocol, const char *service)
BNetAddress(BNetAddress &)
BNetAddress(BMessage *archive)

Sets up the BNetAddress object to refer to the specified address. The address can be specified in a number of ways:

After creating your BNetAddress, you must call InitCheck() to ensure that no errors occurred during setup. You can change the address later by calling SetTo().


~BNetAddress

virtual ~BNetAddress()

A typical destructor.


Member Functions


InitCheck()

status_t InitCheck(void) const

Returns a status_t indicating whether or not the object was successfully instantiated.

RETURN CODES


GetAddr()

status_t GetAddr(char *hostname = NULL, unsigned short *port = NULL) const
status_t GetAddr(struct sockaddr_in &sa) const
status_t GetAddr(in_addr &addr, unsigned short *port = NULL) const

Returns the address represented by the BNetAddress object in the format indicated by the form of the function used.

If you don't care about the hostname (in the first form), you can specify NULL for the hostname argument; if you don't care about the port number, you can specify NULL for the port argument.

RETURN CODES


SetTo()

status_t SetTo(const char *hostname, const char *protocol,
      const char *service)
status_t SetTo(const char *hostname = NULL, unsigned short port = 0)
status_t SetTo(const sockaddr_in &sa)
status_t SetTo(in_addr addr, int port = 0)
status_t SetTo(uint32 addr = INADDR_ANY, int port = 0)

Sets the address represented by the BNetAddress object in the format indicated by the form of the function used. These formats are described in the discussion of the constructor.

RETURN CODES


The Be Book The Network Kit The Network Kit Index

The Be Book,
...in lovely HTML...
for BeOS Release 5.

Copyright © 2000 Be, Inc. All rights reserved..