tfClose
Table of Contents >> Programmer's Reference
| #include <trsocket.h> |
| int tfClose | (int socketDescriptor); |
Function Description
This function is used to close a socket. It is not called close to avoid confusion with an embedded kernel file system call. For reliable transport protocols like TCP, the default action requires that the socket remain in existence for awhile until all in-flight data has been sent and acknowledged by the peer. The default timeout behavior for unsent data can be controlled with the setsockopt() SO_LINGER option.
Parameters
- socketDescriptor
- The socket descriptor to close.
Return Values
- TM_ENOERROR
- Success
- TM_SOCKET_ERROR
- Failure
| TM_SOCKET_ERROR means that this socket call has failed and the errorCode has been set on the socket itself.
To retrieve the socket error the user must call tfGetSocketError(socketDescriptor). |
Possible socket errors
- TM_EBADF
- The socket descriptor is invalid.
- TM_EALREADY
- A previous tfClose() call is already in progress.
- TM_ETIMEDOUT
- The linger option was on with a non-zero timeout value and the linger timeout expired before the TCP (or SCTP) close handshake with the remote host could complete (blocking TCP or SCTP socket only).