SetTCPDisconnectMode
- Updated2023-02-21
- 3 minute(s) read
SetTCPDisconnectMode
int SetTCPDisconnectMode (unsigned int conversationHandle, int disconnectMode);
Purpose
Sets the method used to close the local handle when a remote client or server closes the connection. There are two modes: auto disconnect and manual disconnect.
In the auto disconnect mode (TCP_DISCONNECT_AUTO), the TCP Support Library closes the local conversation handle after the client or server callback is called with the TCP_DISCONNECT message. If, however, the library invokes the TCP_DISCONNNECT message while your program is already nested in a ServerTCPRead or ClientTCPRead call on the same conversation handle, the library does not close the conversation handle until the ServerTCPRead or ClientTCPRead function completes.
In the manual disconnect mode (TCP_DISCONNECT_MANUAL), the TCP Support Library does not close the local conversation handle automatically. You must call DisconnectFromTCPServer or DisconnectTCPClient to close the conversation handle. This method allows you to read data from the connection after you receive a TCP_DISCONNECT for the connection. Close the handle to the connection after you have read all the data.
If you do not call SetTCPDisconnectMode, the TCP Support Library uses the auto disconnect method.
Parameters
Input | ||
Name | Type | Description |
conversationHandle | unsigned int | The conversation handle that uniquely represents the connection between the server and the client. |
disconnectMode | int | The method used to close the local connection handle. Use TCP_DISCONNECT_AUTO or TCP_DISCONNECT_MANUAL. In the auto disconnect mode (TCP_DISCONNECT_AUTO), the TCP Support Library closes the local conversation handle after the client or server callback is called with the TCP_DISCONNECT message. If, however, the library invokes the TCP_DISCONNNECT message while your program is already nested in a ServerTCPRead or ClientTCPRead call on the same conversation handle, the library does not close the conversation handle until the ServerTCPRead or ClientTCPRead function completes. In the manual disconnect mode (TCP_DISCONNECT_MANUAL), the TCP Support Library does not close the local conversation handle automatically. You must call DisconnectFromTCPServer or DisconnectTCPClient to close the conversation handle. This method allows you to read data from the connection after you receive a TCP_DISCONNECT for the connection. Close the handle to the connection after you have read all the data. If you do not call SetTCPDisconnectMode, the TCP Support Library uses the auto disconnect method. |
Return Value
Name | Type | Description |
status | int | Return value indicating whether the function was successful. Unless otherwise
stated, zero represents successful execution and a negative number represents
the error code. You can call the GetTCPSystemErrorString function to obtain a system message that describes the error. The system messages can be more descriptive than the TCP Support Library error codes. To obtain the correct system error message, you must call GetTCPSystemErrorString immediately after calling the TCP Support Library function that failed. For RegisterTCPServer and RegisterTCPServerEx, the return value is the port number assigned by the system if you passed zero for the port and the function was successful. For functions that read or write data (ClientTCPRead, ClientTCPWrite, ServerTCPRead, ServerTCPWrite), if the function was successful, the return value is the number of bytes transferred. You can have a maximum of 255 concurrent conversations and up to 1,024 connections. If you exceed this limit, -kTCP_TooManyConnections will be returned. You may not be able to open the maximum number of connections allowed by LabWindows/CVI because of limitations imposed by the operating system. |
Additional Information
Library: TCP Support Library
Include file: tcpsupp.h
LabWindows/CVI compatibility: LabWindows/CVI 5.0 and later
Example
Refer to tcp\message.cws for an example of using the SetTCPDisconnectMode function.