LassoScript Utility
Basics Browse Detail

[Net->Read]

Tag Link [Net->Read] Category Networking
Type Member Source Available Yes
Support Preferred Version 7.0
Change Unchanged Data Source Any
Output Type Bytes Security None
Implementation LCAPI Sets Lasso 8.5, Lasso 8.0, Lasso 7.0

Description

[Net->Read] is used with TCP connections to read data that has been sent by the remote host. The tag requires a single parameter which is the maximum number of characters to read. The tag will return all data which is available in the connection up to the maximum number of characters.

Syntax

<?LassoScript
Variable: 'Connection' = (Net);
$Connection->(Connect: 'www.example.com', 80);
Variable: 'Length' = $Connection->(Write: 'GET / HTTP/1.0\r\n');
Variable: 'Length' = $Connection->(Write: '\r\n');
Variable: 'Data' = $Connection->(Read: 32768);
...
$Connection->Close;
?>

Parameters

Required Parameters
Maximum The maximum number of characters to read from the connection.

Examples

To connect to a remote server using TCP:

Use the [Net] type and its member tags to establish a TCP connection. The following example opens a blocking TCP connection to the Web server running on an example server and fetches the root document. The result will be an HTML page.

[Variable: 'myConnection' = (Net)]
[$myConnection->(SetBlocking: True)]
[Var: 'Result' = $myConnection->(Connect: 'www.example.com', 80)]
[Fail_If: $Result != Net_ConnectOK, (-1), 'TCP Error']
[Variable: 'Result' = $myConnection->(Write: 'GET / HTTP/1.0\r\n\r\n')]
[Variable: 'Output' = $myConnection->(Read: 32768)]
[$myConnection->(Close)]
[Output: $Output]

<html><head><title>HTML Document</title></head>>body> ...