SecureTcp Object : Close Method |
Visual Basic |
---|
Public Sub Close() |
Use this method only when the State property is tcpConnected; otherwise, a ptNotConnected error is generated.
If Blocked and you wish to cancel the blocking method and release resources, use the Abort method. Using Close when another method is blocking results in a ptBlocked error.
The Abort method performs a "hard close", with a socket LINGER option time of 0. Use Abort instead of Close to prevent the socket from entering a WAIT_STATE and to immediately release it for reuse.
If Timeout is greater than 0, then this method attempts to clear all buffers and performs a graceful close on the socket within the timeout period. The "close socket" system call blocks while closing. If the operation completes within the timeout period, then this method returns successfully. If the operation does not complete within the timeout period (if SendBufferCount is large, for example), then resources are immediately released and a ptTimeout error is generated.
If Timeout is 0, then a non-blocking "close socket" system call is used with the DONTLINGER option set.
The State property is tcpClosed when closing is complete.
This method may generate the following error code (refer to ErrorConstants for a complete list of error codes):