4D Internet Commands v14

TCP_State

Home

 
4D Internet Commands v14
TCP_State

TCP_State 


 

TCP_State ( tcp_ID ; statusCode ) -> Function result 
Parameter Type   Description
tcp_ID  Longint in Reference to an open TCP
statusCode  Integer in TCP status code
Function result  Integer in Error Code

The TCP_State command returns an integer value corresponding to the state of a particular TCP connection.

tcp_ID is a long integer reference to an open TCP session as established with either the TCP_Open or TCP_Listen command.

statusCode is an integer variable returned which corresponds to one of the status codes below.

0Connection Closed
2Listening for an incoming connection
8Established

Example  

This example assumes that a valid TCP connection has already been established and is identified by the Longint value assigned to the $tcp_id variable. In this example, a command is sent to a web server requesting a page of information and then a loop is entered to receive the results. Since web servers automatically close their connnections once they have performed their action, this example keeps receiving until the connection is dropped or an error occurs.

 C_LONGINT($tcp_id)
 C_INTEGER(vState;$err)
 C_TEXT($command;$buffer;$response)
 If(TCP_Send($tcp_id;$command)=0)
    vState:=0
    Repeat
       $err:=TCP_Receive($tcp_id;$buffer)
       $err:=TCP_State($tcp_id;vState)
       $response:=$response+$buffer
    Until((vState=0)|($err#0))
 End if

 
PROPERTIES 

Product: 4D Internet Commands
Theme: IC TCP/IP
Number: 88929

 
HISTORY 

Created: 4D Internet Commands 6.5

 
SEE ALSO 

TCP_Listen
TCP_Open

 
ARTICLE USAGE

4D Internet Commands ( 4D Internet Commands v11.4)
4D Internet Commands ( 4D v13.2)
4D Internet Commands ( 4D Internet Commands v12.1)
4D Internet Commands ( 4D Internet Commands v14 R2)
4D Internet Commands ( 4D Internet Commands v14)
4D Internet Commands ( 4D Internet Commands v14 R3)
4D Internet Commands ( 4D Internet Commands v14 R4)