Close a socket

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
status = %SS_CLOSE(socket[, SS_PURGE])

Return value


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



A socket descriptor. (i4)


(optional) Do not apply the socket shutdown logic.


%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.