SDK Home Glossary Index Left Right Up

Inet Address


Section contents


Overview

Defined in

csocket.oxh

Description

The Inet address class is derived from the socket address class.

Class table
Class SockAddr InetAddr
Methods CmpPort
Family
Port
SetFamily
SetPort
Address
Cast
CmpAddr
Input
IsClassA
IsClassB
IsClassC
IsClassBroadcast
IsClassMulticast
IsClassWildAddr
IsClassWildPort
Match
MatchMask
Net
NetBroadcast
NetMask
Output
SetAddress
SubNet
SubNetBroadcast

Construction / destruction


NewInetAddr

Usage

this& = NewInetAddr&:

Description

<TBS>

Return Value
this& A handle which represents the created inet address object
Error Handling

If the object could not be created then an error is generated which should be trapped by an ONERR handler.

Example
  LOCAL this&

  this& = NewInetAddr&:
  DeleteInetAddr:(this&) 

NewInetAddr2

Usage

this& = NewInetAddr2&:(address&)

Description

Creates a new Inet Address obhject from and existing address object.

Arguments
address& A handle to a socket address object (or an object derived from a socket address object)
Return Value
this& A handle which represents the created inet address object
Error Handling

If the object could not be created then an error is generated which should be trapped by an ONERR handler.

Example
  LOCAL this&, addr&

  addr& = NewInetAddr4&:(INET_ADDR&:(192,10,1,5),KEchoPort&)
  this& = NewInetAddr2&:(addr&)
  DeleteInetAddr:(this&) 

NewInetAddr3

Usage

this& = NewInetAddr3&:(port&)

Description

<TBS>

Arguments
port& Specifies the port for the address
Return Value
this& A handle which represents the created inet address object
Error Handling

If the object could not be created then an error is generated which should be trapped by an ONERR handler.

Example
  CONST KEchoPort& = 7
  LOCAL this&

  this& = NewInetAddr3&:(KEchoPort&)
  DeleteInetAddr:(this&) 

NewInetAddr4

Usage

this&xi = NewInetAddr4&:(inetAddr&,port&)

Description

<TBS>

Arguments
inetAddr& <TBS>
port& <TBS>
Return Value
this& A handle which represents the created inet address object
Error Handling

If the object could not be created then an error is generated which should be trapped by an ONERR handler.

Example
  CONST KEchoPort& = 7
  LOCAL this&

  this& = NewInetAddr4&:(INET_ADDR&:(192,10,1,5),KEchoPort&)
  DeleteInetAddr:(this&) 

DeleteInetAddr

Usage

DeleteInetAddr:(BYREF this&)

Description

Destroys the internet address object.

Arguments
BYREF this& A handle for an internet address object. A zero value is written back into the variable
Example
  LOCAL this$

  this& = NewInetAddr&:
  DeleteInetAddr:(this&) 

Methods provided


InetAddrAddress

Usage

address& = InetAddrAddress&:(this&)

Description

Returns a long integer value which represents the internet address.

Arguments
this& A handle for an internet address object
Return value
address& An integer value which represents the internet address

InetAddrCast

Usage

address& = InetAddrCast&:(addr&)

Description

<TBS>

Arguments
addr& A handle for an internet address object
Return value
address& A handle for a socket address object

InetAddrCmpAddress

Usage

result% = InetAddrCmpAddress%:(this&,inetAddr&)

Description

<TBS>

Arguments
this& A handle for an internet address object
inetAddr& A handle for an internet address object
Return value
result% <TBS>

InetAddrInput - Convert a string to an address

Usage

result% = InetAddrInput%:(this&,string$)

Description

Attempts to convert the characters in string$ into a valid address. Allows conversion of strings of the form a, a.b, a.b.c, a.b.c.d, or 0xaabbccdd.

Arguments
this& A handle for an internet address object
string$ A string containing the address
Return value
result% Set to KNoError% if the address is successfully converted
Example
  LOCAL this&
  LOCAL result%

  this& = NewInetAddr&:
  result% = InetAddrInput%:(this&,"127.0.0.1")
  IF result%<0
    PRINT "Unable to Input address: "; result%
  ELSE
    PRINT InetAddrOutput$:(this&)
  ENDIF
  DeleteInetAddr:(this&) 

InetAddrIsClassA - Check if address belongs to a Class A network

Usage

result% = InetAddrIsClassA%:(this&)

Description

Checks the address and returns TRUE (-1) if it is a Class A network address. A Class A network address is one whose first byte is in the range 0 to 128. In a Class A address the first byte is the network number and the next three bytes are the host address.

Arguments
this& A handle for an internet address object
Return value
result% Set to -1 if the address belongs to a Class A network, otherwise set to 0
Example
  LOCAL this&
  LOCAL result%

  this& = NewInetAddr2&:(INET_ADDR(192,10,1,5))
  IF InetAddrIsClassA%:(this&)
    PRINT InetAddrOutput$:(this&); " is a class A network address"
  ELSE
    PRINT InetAddrOutput$:(this&); " is not a class A network address"
  ENDIF
  DeleteInetAddr:(this&) 

InetAddrIsClassB - Check if address belongs to a Class B network

Usage

result% = InetAddrIsClassB%:(this&)

Description

Checks the address and returns TRUE (-1) if it is a Class B network address. A Class B network address is one whose first byte is in the range 128 to 191. In a Class B address the first two bytes identify the network and the next two bytes identify the host.

Arguments
this& A handle for an internet address object
Return value
result% Set to -1 if the address belongs to a Class B network, otherwise set to 0
Example
  LOCAL this&
  LOCAL result%

  this& = NewInetAddr2&:(INET_ADDR(192,10,1,5))
  IF InetAddrIsClassB%:(this&)
    PRINT InetAddrOutput$:(this&); " is a class B network address"
  ELSE
    PRINT InetAddrOutput$:(this&); " is not a class B network address"
  ENDIF
  DeleteInetAddr:(this&) 

InetAddrIsClassBroadcast - Check if address is 255.255.255.255

Usage

result% = InetAddrIsClassBroadcast%:(this&)

Description

Checks the address and returns TRUE (-1) if it is 255.255.255.255.

Arguments
this& A handle for an internet address object
Return value
result% Set to -1 if the address is 255.255.255.255, otherwise set to 0

InetAddrIsClassC - Check if address belongs to a Class C network

Usage

result% = InetAddrIsClassC%:(this&)

Description

Checks the address and returns TRUE (-1) if it is a Class C network address. A Class C network address is one whose first byte is in the range 192 to 223. In a Class C address the first three bytes identify the network and the last bytes identifies the host.

Arguments
this& A handle for an internet address object
Return value
result% Set to -1 if the address belong to a Class C network, otherwise set to 0
Example
  LOCAL this&
  LOCAL result%

  this& = NewInetAddr2&:(INET_ADDR(192,10,1,5))
  IF InetAddrIsClassC%:(this&)
    PRINT InetAddrOutput$:(this&); " is a class C network address"
  ELSE
    PRINT InetAddrOutput$:(this&); " is not a class C network address"
  ENDIF
  DeleteInetAddr:(this&) 

InetAddrIsClassMulticast

Usage

result% = InetAddrIsClassMulticast%:(this&)

Description

<TBS>

Arguments
this& A handle for an internet address object
Return value
result% Set to -1 if the address is a multicast address, otherwise set to 0

InetAddrIsClassWildAddr - Check if address is 0.0.0.0

Usage

result% = InetAddrIsClassWildAddr%:(this&)

Description

<TBS>

Arguments
this& A handle for an internet address object
Return value
result% Set to -1 if the address is 0.0.0.0, otherwise set to 0

InetAddrIsClassWildPort - Check if port is 0

Usage

result% = InetAddrIsClassWildPort%:(this&)

Description

<TBS>

Arguments
this& A handle for an internet address object
Return value
result% Set to -1 if the port is 0, otherwise set to 0

InetAddrMatch

Usage

result% = InetAddrMatch%:(this&,inetAddr&)

Description

<TBS>

Arguments
this& A handle for an internet address object
inetAddr& A handle for an internet address object
Return value
result% <TBS>

InetAddrMatchMask

Usage

result% = InetAddrMatchMask%:(this&,inetAddr&,mask&)

Description

<TBS>

Arguments
this& A handle for an internet address object
inetAddr& A handle for an internet address object
mask& <TBS>
Return value
result% <TBS>

InetAddrNet

Usage

InetAddrNet:(this&,inetAddr&)

Description

<TBS>

Arguments
this& A handle for an internet address object
inetAddr& A handle for an internet address object

InetAddrNetBroadcast

Usage

InetAddrNetBroadcast:(this&,inetAddr&)

Description

<TBS>

Arguments
this& A handle for an internet address object
inetAddr& A handle for an internet address object

InetAddrNetMask

Usage

InetAddrNetMask:(this&,inetAddr&)

Description

<TBS>

Arguments
this& A handle for an internet address object
inetAddr& A handle for an internet address object

InetAddrOutput - Create string representation of the address

Usage

string$ = InetAddrOutput$:(this&)

Description

Converts the internal address representation to a string.

Arguments
this& A handle for an internet address object
Return value
string$ A string representation of the address
Example
  LOCAL this&
  LOCAL result%

  this& = NewInetAddr&:
  result% = InetAddrInput%:(this&,"127.0.0.1")
  IF result%<0
    PRINT "Unable to Input address: "; result%
  ELSE
    PRINT InetAddrOutput$:(this&)
  ENDIF
  DeleteInetAddr:(this&) 

InetAddrSetAddress

Usage

InetAddrSetAddress:(this&,inetAddr&)

Description

<TBS>

Arguments
this& A handle for an internet address object
inetAddr& A handle for an internet address object
Example
  LOCAL this&

  this& = NewInetAddr&:
  InetAddrSetAddress:(this&,INET_ADDR&:(192,10,1,5))
  PRINT InetAddrOutput$:(this&)
  DeleteInetAddr:(this&) 

InetAddrSubNet

Usage

InetAddrSubNet:(this&,inetAddr&)

Description

<TBS>

Arguments
this& A handle for an internet address object
inetAddr& A handle for an internet address object

InetAddrSubNetBroadcast

Usage

InetAddrSubNetBroadcast:(this&,inetAddr&)

Description

<TBS>

Arguments
this& A handle for an internet address object
inetAddr& A handle for an internet address object

Utility Routines


INET_ADDR

Usage

ipaddress&xi = INET_ADDR&:(val1%,val2%,val3%,val4%)

Description

Combines the four parameters into a single long integer.

Arguments
val1% The first byte of the address
val2% The second byte of the address
val3% The third byte of the address
val4% The fourth byte of the address
Return value
ipaddress& A long integer which represents the Internet address
Example
  LOCAL this&

  this& = NewInetAddr2&:(INET_ADDR(192,10,1,5))
  DeleteInetAddr:(this&) 

  SDK Home Glossary Index Left Right Up