Skip to main content
Open topic with navigation

CAPL Functions » TLS API » tlsClose

Function Syntax

long tlsClose(dword socket, dword closeUnderlyingSocket);

Description

Closes the given TLS connection. This sends a TLS alert message to the peer node. The underlying socket will be closed automatically if the parameter closeUnderlyingSocket is set to a value greater than 0.

Parameters

  • socket: The socket handle.
  • closeUnderlyingSocket:
    • 0: do not close underlying socket.
    • unequal 0: close the underlying socket.

Return Values

  • 0: The function completed successfully.
  • WSA_INVALID_PARAMETER (87): The specified socket was invalid.
  • SOCKET_ERROR (-1): The function failed. Call IpGetLastSocketError to get a more specific error code. If the specific error code is 997, this just indicates an asynchronous operation is in progress.
  • TLS_ERROR (-2): The function failed. Call tlsGetLastError to get a more specific error code. If the specific error code is 997, this just indicates an asynchronous operation is in progress.

Example

void ClientStop()
{
  //
  // Close TLS socket and underlying socket
  //

  tlsClose(gTlsClientSocket, 1);
  gTlsClientSocket = 0;
}