|
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.
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:
- By hostname and port number. For example, to connect to the HTTP port at www.be.com, you would specify "www.be.com" as the hostname, and 80 for the port number.
- By sockaddr_in structure. This structure contains the network family, port number, and IP address that make up the address.
- By IP address and port number. The IP address can be specified either using an in_addr, or by using a uint32. The IP address must be specified in network byte order. See the htonl() function.
- By hostname, protocol, and service name. This causes the port to be looked up in the /etc/services file by matching the protocol (typically "tcp" or "udp") and service name (such as "http" or "ftp") against the entries in the file. See getservbyname() for details on the format of this file.
- By copying an existing BNetAddress.
- By unflattening an archived BNetAddress from a BMessage.
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.
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) constReturns 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
|
Copyright © 2000 Be, Inc. All rights reserved..