Use TcpStatus to obtain the current status of a TCP connection.
Your program sets the Connection field of the ConnectionInfo record
to the number of the connection whose status you want. Figure 1 shows an example of TcpStatus.
Figure 1. TcpStatus example procedure TcpStatus
(
var ConnectionInfo: StatusInfoType;
var ReturnCode: integer
);
external;
- Parameter
- Description
- ConnectionInfo
- If ReturnCode is OK, the following
fields are returned.
- OpenAttemptTimeout
- If the connection is in the process of being opened (including
a passive open), this field is set to the number of seconds remaining
before the open is terminated if it has not completed. Otherwise,
it is set to WAITforever.
- BytesToRead
- The number of bytes of incoming data queued for your program (waiting
for TcpReceive, TcpFReceive, or TcpWaitReceive).
- UnackedBytes
- The number of bytes sent by your program but not yet sent to the
foreign TCP, or the number of bytes sent to the foreign TCP, but not
yet acknowledged.
- ConnectionState
- The current connection state.
- LocalSocket
- The local socket, consisting of a local address and a local port.
- ForeignSocket
- The foreign socket, consisting of a foreign address and a foreign
port.
- ReturnCode
- Indicates the success or failure
of the call. Possible return values are:
- OK
- NOsuchCONNECTION
- NOTyetBEGUN
- TCPipSHUTDOWN
- REMOTEreset
- SOFTWAREerror
For a description of Pascal return codes, see
Table 1.
Note: Your program cannot
monitor connection state changes exclusively through polling with
TcpStatus. It must receive CONNECTIONstateCHANGED notifications through
GetNextNote for the TCP interface to work properly.