Command TCP_Receive

4D Internet Commands

TCP_Receive

version 6.5


TCP_Receive (tcp_ID; text) Integer

ParameterTypeDescription
tcp_IDLongintReference to an open TCP session
textTextReceived Text

Function result Integer Error Code

Description

Given a long integer reference to an established TCP Session, the TCP_Receive command receives packets of data into text.

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

text is the text received. When receiving data via TCP packets, you cannot count on all of your data being received by a single TCP_Receive call. The TCP_Receive command is usually called within a Repeat loop which continually checks on the status of the connection or is scanning for a known value.

Example

   C_LONGINT($tcp_id)
   C_TEXT($webpage;$buffer)
   C_INTEGER(vState;$error)
   $webpage:=""
   vState:=0
   Repeat 
      $error:=TCP_Receive ($tcp_id;$buffer)
      $error:=TCP_State ($tcp_id;vState)
      $webpage:=$webpage+$buffer
   Until ((vState=0) | ($error#0))  until host closes connection or an error

See Also

TCP_Send, TCP_SendBLOB.