RtnAttachProcessExitHandler

RtnAttachProcessExitHandler registers an application's networking exit handler to allow an RTSS application to perform custom socket code cleanup when an application exits.

Syntax

BOOL RtnAttachProcessExitHandler(
    LPTHREAD_START_ROUTINE pRoutine,
    LPVOID pContext,
    ULONG Priority
);

Parameters

pRoutine

The handler function to register

pContext

The argument to the handler routine.

Priority

Thread priority to run the networking exit handler.

Return Value

Returns TRUE when a process handler has been registered. Returns FALSE when an error occurs during an attempt to register an exit handler. You can retrieve an error code using WSAGetLastError. The possible error codes are listed below:

Error Code Meaning
WSAEINVAL pRoutine is a NULL pointer or Priority is greater than RT_PRIORITY_MAX (127).
WSAENETDOWN The RT-TCP/IP Stack is not running.
WSANOTINITIALISED A successful WSAStartup has not been executed.
WSAEALREADY The exit handler has been already registered.

Remarks

This callback is particularly useful when used to replace socket code cleanup intended to be called on DLL_PROCESS_DETACH. Socket code cleanup on DLL_PROCESS_DETACH is not allowed in RTSS applications.

Only one networking exit handler is allowed per application process.

Valid WSAStartup must complete before RtnAttachProcessExitHandler is called. The final WSACleanup, which performs actual socket cleanup, removes the exit handler.

This exit handler can also be removed by calling RtnReleaseProcessExitHandler.

WSACleanup is allowed to be called from this networking exit handler.

This exit handler executes when the process exits before any DLLs are unloaded.

Requirements

Minimum Supported Version RTX64 3.0 Update 1with Service Pack 1
Header rtnapi.h
Library RtTcpip.lib

See Also:

RtnReleaseProcessExitHandler