Skip to main content
Open topic with navigation

CAPL Functions » TCP/IP API » OnTcpClose

Function Syntax

void OnTcpClose( dword socket, long result);

Method Syntax

void OnTcpClose( TcpSocket socket, long result);

Description

If the CAPL program implements this callback it is called when a TCP socket receives a close notification, when the remote station terminates the connection with TcpClose or TcpShutdown. To release the resources of the socket, TcpClose must be called.

Parameters

  • socket: The socket handle or socket object.
  • result: The specific result code of the operation. If the operation completed successfully the value is 0. Otherwise the value is an error code. Typical errors are interrupt of the connection, timeout or reset.

Return Values

Example

// ---------------------------------------------------
// TCP socket receives a close notification
// ( remote disconnected )
// ---------------------------------------------------

void OnTcpClose( dword socket, long result)
{
  writeLineEx(1, 1, " [ OnTcpClose called. (socket: %d, result: %d) ]", socket, result);
  TcpClose(socket);
}
Create TCP Client and Server Sockets