z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


CLOSE

z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
SC27-3660-00

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.

Format

Read syntax diagramSkip visual syntax diagram
>>-SOCKET--(--"CLOSE"--,--socketid--)--------------------------><

Parameters

socketid
The socket descriptor

Returned value

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.

The following REXX TCP/IP error numbers can be returned:
  • 9 EBADF
The following REXX socket API error numbers can be returned:
  • 2001 EINVALIDRXSOCKETCALL
  • 2009 ESOCKETNOTDEFINED

LE C/C++ equivalent

int close(int socket); 

Code example

Figure 1. CLOSE command example
/* 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;

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014