SockAccept | Called by a REXX script running upon a server to accept a connection from a client. |
SockConnect | Connects a client script to a server script running on another computer. |
Called by a REXX script running upon a server to accept a connection from a client.
Calls the sockets library's accept() function.
Synopsis
clientsocket = SockAccept(socket, 'client.', async, id)
socket is the server's socket returned by SockSocket.
client. is the name of a stem variable that SockAccept fills in with information about the client that has been "accepted". SockAccept fills in the REXX compound variable client.FAMILY with the client's Address Family, client.PORT with the client's port number, client.ADDR with the client's dotted IP Address, and client.ID with the socket's ID number (as may be returned by SockGetId). If client. is omitted, no such information is returned.
async is a 1 if the accepted socket is to be put into non-blocking mode, or a 0 if blocking. Omit this arg to use the default mode (which is usually blocking).
id is the ID number you wish associated with the client socket. If omitted, then RexxSock will pick out a unique ID number suitable for use with SockSelect, and you can retrieve that ID number with a call to SockGetId.
Returns
Notes
The specific error name can be retrieved via ErrNo, and any error message retrieved via SockErrMsg.
The client socket should eventually be closed with SockClose after the server script is done receiving or sending data to the client. Note that RexxSock will automatically close handles if your script neglects to do so, when your script terminates.
Connects a client script to a server script running on another computer. This must be done once by a client script before calling any RexxSock function to send or receive data from that server.
Calls the sockets library's connect() function.
Synopsis
err = SockConnect(socket, 'peer.', protocol, async, id)
socket is a local socket returned by SockSocket.
peer. is a stem variable that should be filled in prior to the call to SockConnect. peer.FAMILY is a string that represents the addressing family, usually "AF_INET" for internet style addressing. peer.PORT is the port number on the peer to connect to. peer.ADDR is the peer's (ie, other computer's) dotted IP address (as may be returned by SockGetHostByName) or the computer's network name (as may be returned by SockGetHostByAddr).
If protocol is not omitted, then SockConnect creates a new socket of type SOCK_STREAM (ie, so you won't have to call SockSocket prior to SockConnect in order to do that). In this case, protocol is the desired protocol (ie, the same as the protocol arg passed to SockSocket), and socket is instead the name of the stem variable which SockConnect will set to the created socket.
async is a 1 if the socket is to be put into non-blocking mode. If omitted, then socket's mode is not changed.
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. id is used only if you also pass protocol. Otherwise, it is ignored.
For Windows, async is instead a handle to some window which will be sent a message when the connection is made, followed by a space, and then the message number to be used. The socket will be put into non-blocking mode, suitable for use with SockAsyncSelect.
Returns
Notes
The specific error name can be retrieved via ErrNo, and any error message retrieved via SockErrMsg.
SockConnect is used by a client to create a connection to a particular computer. socket specifies an unconnected datagram or stream socket. If the socket has not previously been bound with SockBind, then unique values are assigned to the local association by the system, and the socket is marked as bound. Note that if peer.ADDR is all zeroes, SockConnect will set ErrNo = "EADDRNOTAVAIL". For stream sockets (type SOCK_STREAM), an active connection is initiated to the remote computer using peer.ADDR and peer.PORT. When SockConnect completes successfully, the socket is ready to send and receive data. For a datagram socket (type SOCK_DGRAM), a default destination is set, which will be used on subsequent SockSend and SockRecv calls.