Use the FCNTL command to control the operating characteristics of a socket.
.-,--BLOCKING-. >>-SOCKET--(--"FCNTL"--,--socketid--,--fcmd--+-------------+----> '-,--fvalue---' >--)-----------------------------------------------------------><
The command returns a string that contains the return code. If the F_GETFL flag is issued, the string also contains the flag. 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.
The string 0 BLOCKING is an example of what this command might return.
See Socket call error return codes for additional information about the numeric error codes that are returned by this command.
int fcntl(int socket, int cmd, ...);
/* REXX EXARXR04 */
/*
* This sample demonstrates the use of the FCNTL
* socket command.
*
* The program will open a STREAM socket and use the
* FCNTL command to set the socket to NON-BLOCKING
* mode.
*/
src = socket("INITIALIZE","MYSET01");
if perror(src,"INITIALIZE") = 0 then do
src = socket("SOCKET","AF_INET","STREAM");
if perror(src,"SOCKET") = 0 then do
l_socketid = WORD(src,2);
src = socket("FCNTL",l_socketid,F_SETFL,"NON-BLOCKING");
src = socket("FCNTL",l_socketid,F_GETFL);
Say src;
end; /* SOCKET */
src = socket("CLOSE",l_socketid);
src = perror(src,"CLOSE");
end;
src = socket("TERMINATE","MYSET01");
src = perror(src,"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;