%SS_CLOSE

Close a socket

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
status = %SS_CLOSE(socket[, SS_PURGE])

Return value

status

Returns SS_SUCCESS (0) or one of the errors in Error codes returned by %SS_CLOSE below. (n)

Arguments

socket

A socket descriptor. (i4)

SS_PURGE

(optional) Do not apply the socket shutdown logic.

Discussion

%SS_CLOSE closes a connection and deletes a socket descriptor.

%SS_CLOSE follows recommended techniques to ensure that all data from a remote client is silently received and ignored (to avoid the remote socket appearing hung). This assumes that the remote application correctly closes down the socket when the protocol is finished. It forces the underlying TCP/IP transport to cleanly terminate and reduces dangling socket problems in the operating system. Under error conditions, or if an application sends data and never expects a response, the optional SS_PURGE flag should be specified to avoid making the shutdown algorithm hang.

On Unix, you may want to specify SS_PURGE when using the FORK subroutine on a process to ensure that the FORK’d process does not force the connection to be terminated for the parent process when it closes the socket. The accepted socket (with %SS_ACCEPT or %SS2_ACCEPT) on the server should be purged only after it knows the client has cloned the socket and is using it, because the child now owns the socket. The server socket should be purged in the child program.

Error codes returned by %SS_CLOSE

See the Socket Errors table for additional information about these errors.

SS_EBADF

SS_EINTR

SS_ENETDOWN

SS_ENETUNREACH

SS_ENOTSOCK

SS_EUNKNOWN

SS_NOTINITIALISED