SockGetHostByAddr | Converts a dotted IP address to a TCP/IP alias (ie, network name). |
SockGetHostByName | Converts TCP/IP alias to a dotted IP address. |
SockGetHostId | Gets the local dotted IP address (ie, the address of the machine upon which the script is run). |
SockGetPeerName | Gets the dotted IP address of the computer (peer) to which the system running the REXX script is connected. |
SockGetSockName | Gets the local name for a socket. |
Converts a dotted IP address to a TCP/IP alias (ie, network name). This is the complement to SockGetHostByName.
Calls sockets library's gethostbyaddr() function.
Synopsis
err = SockGetHostByAddr(address, 'host.', domain)
Args
address is the dotted IP address.
host. is the name of the stem variable whose tails host.ADDRTYPE, host.ADDR, and host.NAME will be set (by SockGetHostByAddr) to the host's Address Family (ie, "AF_INET"), the host's dotted IP address, and the alias name, respectively. Furthermore, host.ALIAS.0 will be set to the number of alias names the host has. The variables host.ALIAS.1 through host.ALIAS.[host.ALIAS.0] will be those alias names. host.ADDR.0 will be set to the number of alias addresses the host has. The variables host.ADDR.1 through host.ADDR.[host.ADDR.0] will be those alias addresses.
domain must be the string "AF_INET". (ie, RexxSock supports only internet domain connections). If omitted, it defaults to "AF_NET".
Returns
1 if success, or 0 if gethostbyaddr() fails.
Notes
The specific error name can be retrieved via ErrNo, and any error message retrieved via SockErrMsg.
Converts a TCP/IP alias to a dotted IP address. For example, passing an alias of "microsoft.com" will look up and return the dotted IP address for "microsoft.com".
Calls the sockets library's gethostbyname() function.
Synopsis
err = SockGetHostByName(name, 'host.')
Args
host. is the name of the stem variable whose tails host.ADDRTYPE, host.ADDR, and host.NAME will be set to the host's Address Family (ie, "AF_INET"), the host's dotted IP address, and the alias name, respectively. Furthermore, host.ALIAS.0 is set to the number of alias names the host has. The variables host.ALIAS.1 through host.ALIAS.[host.ALIAS.0] will be those alias names. host.ADDR.0 is set to the number of alias addresss the host has. The variables host.ADDR.1 through host.ADDR.[host.ADDR.0] will be those alias addresses.
Returns
1 if success, or 0 if gethostbyname() fails.
Notes
The specific error name can be retrieved via ErrNo, and any error message retrieved via SockErrMsg.
Gets the local dotted IP address (ie, the address of the machine upon which the script is run).
Calls the sockets library's gethostid() function.
Synopsis
address = SockGetHostId()
Returns
Notes
The specific error name can be retrieved via ErrNo, and any error message retrieved via SockErrMsg.
Gets the dotted IP address of the computer (peer) to which the system running the REXX script is connected.
Calls sockets library's getpeername() function.
Synopsis
err = SockGetPeerName(socket, 'peer.')
Args
socket is the socket of the peer computer (gotten via SockAccept).
peer. is the name of the stem variable whose tails, peer.FAMILY, peer.PORT, and peer.ADDR will be set (by SockGetPeerName) to the Address Family, Port number, and dotted IP address of the peer.
Returns
Notes
The specific error name can be retrieved via ErrNo, and any error message retrieved via SockErrMsg.
Gets the local name for the specified socket.
Calls the sockets library's getsockname() function.
Synopsis
err = SockGetSockName(socket, 'addr.')
Args
socket is the socket returned by SockSocket.
addr. is the name of the stem variable whose tails, addr.FAMILY, addr.PORT, and addr.ADDR will be set to the Address Family, Port number, and dotted IP address of the local socket.
Returns
Notes
The specific error name can be retrieved via ErrNo, and any error message retrieved via SockErrMsg.
SockGetSockName retrieves the current name for the specified socket. It is used on a bound or connected socket. The local association is returned. This call is especially useful when SockConnect has been called without doing a SockBind upon that socket first; SockGetSockName provides the only means by which you can determine the local association set by the system.
If a socket was bound to INADDR_ANY (indicating that any of the host's IP addresses should be used for the socket), then SockGetSockName will not be able to definitively return the host's IP address (in addr.ADDR), unless the socket has been connected with SockConnect or SockAccept. A script must not assume that addr.ADDR will be accurate until/unless the socket is connected. This is because for a multi-homed host, the IP address that will be used for the socket is unknown until the socket is actually connected.