The following functions initialize REXXSOCK and create sockets:

SockInit Enables/disables REXXSOCK features.
SockSocket Creates a socket.


SockInit

Enables/disables REXXSOCK features.

Synopsis

err = SockInit(UserNumber, UseSockErrNo)

Args


UserNumber is the USER condition number to raise if an REXXSOCK function fails. For example, passing a 1 will use USER condition 1. Omitting this arg will mean that REXXSOCK functions do not raise a condition, and the returns will have to be error checked manually. This is applicable only if using the Reginald REXX interpreter.

UseSockErrNo is a 1 if you wish REXXSOCK to set the variable name SockErrNo (instead of ErrNo). This may help to avoid a situation where your script (or some other add-on DLL) inadvertently uses the variable ErrNo for some other purpose. Omitting this arg will mean that REXXSOCK uses ErrNo.

Returns

0 if success, or 1 if an error.

Notes

There are some REXXSOCK functions that do not raise USER condition even for an error. They are SockLoadFuncs, SockDropFuncs, SockErrMsg, SockInit, SockPSock_Errno, SockSock_Errno, SockGetHandle, SockGetId, SockExit, and SockMaxPacketSize.

See Error Names for more information about handling errors.

You can call SockInit() repeatedly to change the USER condition, or turn it off.

See Also
SockExit


SockSocket

Creates a socket.

A socket must be created in order to be able to connect to another computer. This must be done once prior to actually connecting to, and then sending data to and/or receiving data from, that other computer.

Calls the socket library's socket() function.

Synopsis

socket = SockSocket(domain, type, protocol, 'assoc.', backlog, id)

Args

domain must be the string "AF_INET" (ie, REXXSOCK supports only internet domain connections). If omitted, defaults to "AF_INET".

type is one of the strings: "SOCK_STREAM", "SOCK_DGRAM", or "SOCK_RAW". The first supports bi-directional (full duplex) communication between two computers. The latter two operate connectionless by sending only messages from the "server" (ie, sender) to the "client" (ie, recipient). If omitted, defaults to "SOCK_STREAM".

protocol is one of the strings: "IPPROTO_UDP", "IPPROTO_TCP" (ie, TCP/IP protocol), or 0 if you do not wish to specify a protocol. (ie, The sockets library chooses a default protocol for you). If omitted, defaults to "IPPROTO_TCP".

'assoc.' is the same as the arg passed to SockBind. If you do not omit it here, then you do not need to call SockBind later. (ie, This is meant to be a convenience).

backlog is the same as the arg passed to SockListen. If you do not omit it here, then you do not need to call SockListen later.

id is the ID number you wish associated with this socket. If omitted, then REXXSOCK will pick out a unique ID number suitable for use with SockSelect's callback feature, and you can retrieve that ID number with a call to SockGetId.

Returns


The socket (which will be passed to many of the other REXXSOCK functions you call).

Notes

The specific error name can be retrieved via ErrNo, and any error message retrieved via SockErrMsg.