IPAddress Class Reference

#import <IPAddress.h>

Inherited by HostAddress, and RecentAddress.

List of all members.


Detailed Description

Represents an Internet Protocol address and port number (similar to a sockaddr_in).

IPAddress itself only remembers the raw 32-bit IPv4 address; the subclass HostAddress also remembers the DNS host-name.

Public Member Functions

(id) - initWithHostname:port:
 Initializes an IPAddress from a host name (which may be a DNS name or dotted-quad numeric form) and port number.
(id) - initWithIPv4:port:
 Initializes an IPAddress from a raw IPv4 address (in network byte order, i.e.
(id) - initWithIPv4:
 Initializes an IPAddress from a raw IPv4 address (in network byte order, i.e.
(id) - initWithSockAddr:
 Initializes an IPAddress from a BSD struct sockaddr.
(BOOL) - isSameHost:
 Returns YES if the two objects have the same IP address, ignoring port numbers.

Static Public Member Functions

(IPAddress *) + localAddress
 Returns the IP address of this host (with a port number of zero).
(IPAddress *) + addressOfSocket:
 Returns the address of the peer that an open socket is connected to.

Properties

readonly UInt32 ipv4
 The raw IPv4 address, in network (big-endian) byte order.
readonly NSString * ipv4name
 The address as a dotted-quad string, e.g.
readonly NSString * hostname
 The address as a DNS hostname or else a dotted-quad string.
readonly UInt16 port
 The port number, or zero if none was specified, in native byte order.
readonly BOOL isPrivate
 Is this IP address in a designated private/local address range, such as 10.0.1.X? If so, the address is not globally meaningful outside of the local subnet.


Member Function Documentation

- (id) initWithHostname: (NSString*)  hostname
port: (UInt16)  port 

Initializes an IPAddress from a host name (which may be a DNS name or dotted-quad numeric form) and port number.

If the hostname is not in dotted-quad form, an instance of the subclass HostAddress will be returned instead.

Reimplemented in HostAddress.

- (id) initWithIPv4: (UInt32)  ipv4
port: (UInt16)  port 

Initializes an IPAddress from a raw IPv4 address (in network byte order, i.e.

big-endian) and port number (in native byte order)

- (id) initWithIPv4: (UInt32)  ipv4  

Initializes an IPAddress from a raw IPv4 address (in network byte order, i.e.

big-endian). The port number defaults to zero.

- (id) initWithSockAddr: (const struct sockaddr*)  sockaddr  

Initializes an IPAddress from a BSD struct sockaddr.

+ (IPAddress *) localAddress  

Returns the IP address of this host (with a port number of zero).

If multiple network interfaces are active, the main one's address is returned.

+ (IPAddress *) addressOfSocket: (CFSocketNativeHandle)  socket  

Returns the address of the peer that an open socket is connected to.

(This calls getpeername.)

- (BOOL) isSameHost: (IPAddress*)  addr  

Returns YES if the two objects have the same IP address, ignoring port numbers.


Property Documentation

- (readonly UInt32) ipv4

The raw IPv4 address, in network (big-endian) byte order.

- (NSString *) ipv4name

The address as a dotted-quad string, e.g.

@"10.0.1.1".

- (NSString *) hostname

The address as a DNS hostname or else a dotted-quad string.

(IPAddress itself always returns dotted-quad; HostAddress returns the hostname it was initialized with.)

- (readonly UInt16) port

The port number, or zero if none was specified, in native byte order.

- (BOOL) isPrivate

Is this IP address in a designated private/local address range, such as 10.0.1.X? If so, the address is not globally meaningful outside of the local subnet.


The documentation for this class was generated from the following files:
Generated on Tue May 27 22:56:33 2008 for MYNetwork:MooseyardNetworking by  doxygen 1.5.4