Use the CLOSE command to close a socket and release the resources that are associated with the socket descriptor.
If the socket descriptor is a connected stream socket, the connection to the remote host is also closed. If a connected stream socket is closed but has input data still pending on the socket, the CLOSE command causes the connection to be reset.
The return code can be 0, a REXX socket API error number, or the REXX TCP/IP error number that is set by the socket command. The return code 0 indicates that the requested socket command was completed successfully.
See Socket call error return codes for additional information about the numeric error codes that are returned by this command.
int close(int socket);
/* REXX EZARXR02 */
/*
* This sample demonstrates the use of the CLOSE socket commands.
* The program will open a STREAM socket, and if successful,
* the socket will be closed.
*/
src = socket("INITIALIZE","MYSET01",10);
if perror(src,"INITIALIZE") = 0 then do
src = socket("SOCKET","AF_INET6","STREAM");
if perror(src,"SOCKET") = 0 then do
parse var src l_retcode l_sockid
src = perror(socket("CLOSE",l_sockid),"CLOSE");
end; /* SOCKET */
end; /* INITIALIZE */
src = perror(socket("TERMINATE","MYSET01"),"TERMINATE");
exit 0;
/* This routine returns -1 if the first word if arg 1 is not zero */
perror: if word(arg(1),1) = 0 then return 0; else
Say arg(2) "Error : "arg(1);
return -1;