LassoScript Utility
Basics Browse Detail


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


[Net->Write] is used with TCP connections to send data to a remote host. [Net->Write] is used either to send commands to a remote host using an outgoing connection or to send responses back to a remote host using an incoming connection.

[Net->Write] requires a single parameter which is the data string to be written into the connection. An optional second and third parameter specify an offset and length in the data to be written. This allows only a portion of a string to be written for protocols which require data to be formatted in blocks.

The tag returns the number of bytes that were written into the connection.


Variable: 'Connection' = (Net);
$Connection->(Connect: '', 80);
Variable: 'Length' = $Connection->(Write: 'GET / HTTP/1.0\r\n');
Variable: 'Length' = $Connection->(Write: '\r\n');


Required Parameters
Data The data to be written into the connection.
Optional Parameters
Offset Optional offset into the data to be written.
Length Optional length of the data to be written.


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: '', 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)]
[Output: $Output]

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