Chapter 3. Parameters and Return Values

Unless otherwise stated, the return values are the same as for the corresponding C functions. The following standard parameter types are referred to throughout this reference:

socket

is a socket value, which is an integral number.

domain

is a domain value. Currently, only the domain AF_INET is supported.

address

is the stem of a stem variable with the following values:

address.family

must always be AF_INET.

address.port

is a port number.

address.addr

is a dotted decimal address or INADDR_ANY, where appropriate.

When this parameter is needed, set it the name of a stem variable for the function to set (or that the function will read from). For example, if you pass the string xxx.! as a parameter, the following variables are set or queried by the function:

"xxx.!family"
"xxx.!port"
"xxx.!addr"

A null address is an address with the family field being AF_INET, the port field being 0, and the addr field being 0.0.0.0.

dotAddress

is the standard dotted decimal address. For example, the string 9.23.19.63 is a valid address.

host

is the stem of a stem variable with the following values:

host.name

is the standard name of the host.

host.alias.0

is the number of aliases for this host.

host.alias.1

is the first alias for this host.

host.alias.n

is the nth alias for this host.

host.addrtype

must always be AF_INET.

host.addr

is a dotted decimal address (default address).

host.addr.0

is the number of addresses for this host.

host.addr.1

is the first address for this host.

host.addr.n

is the nth address for this host.

When this parameter is needed, set it the name of a stem variable for the function to set (or that the function will read from). For example, if you pass the string xxx.! as a parameter, the following variables are set or queried by the function:

"xxx.!name"
"xxx.!alias.0", "xxx.!alias.1" ... "xxx.!alias.n"
"xxx.!addrtype"
"xxx.!addr"
"xxx.!addr.0", "xxx.!addr.1" ... "xxx.!addr.n"

Stem Variables

The address and host type of a parameter are stems of a stem variable. Normally, when you pass a string like addr. as a parameter, you expect the variables addr.family, addr.port, and addr.addr to be set by the function. In the previous examples, however, the stem contained an exclamation mark. This exclamation mark helps prevent the value that follows from getting misused as a normal variable. Example:

port = 923
sNew = SockAccept(sOld,"addr.")
say addr.port

In this example, you might expect the say statement to write the port number of the accepted socket. Instead, it writes the value of the variable, namely addr.923, because the port variable is set to this value.

Because exclamation marks are rarely used in variables, it is unlikely that the variable !port is used in your program.

Note: Do not use the characters _, 0, and 1 to prefix tail values. 0 and 1 are difficult to distinguish from O, I, and l.