Lasso Soft Inc. > Home

[ net_tcp ]

Type

[net_tcp] creates a network socket object and provides methods to be used for network communication via TCP. Accepts an optional parameter of a file descriptor.

When using the ->readObject and ->writeObject methods, the object gets copied and can be sent between threads. If the object is serializable, it can be sent over the network connection as well.

  • Syntax
  • Methods
  • Traits
local('Variable Name') = net_tcp
local('Variable Name') = net_tcp(File Descriptor)
Has methods:
Examples
  • Beginner

To create a network socket connection:

Use the [net_tcp] method. The following example creates a network socket connection via TCP, connects to an URL, writes bytes to the URL, reads the response from the server, then outputs the result.

Code

local(c) = net_tcp
'Connect: ' + #c->connect('www.lassosoft.com', 80)+'\n'
'Write: ' + #c->writeBytes('GET / HTTP/1.1
Host: www.lassosoft.com
Accept: */*

'->asbytes) + '\n'
'Read: '+ #c->readSomeBytes(10000,1) + '\n'
#c->close

Result

Connect: true Write: 52 Read: HTTP/1.1 200 OK Date: Mon, 11 Apr 2011 11:48:25 GMT Server: Apache/2.2.3 (CentOS) X-Powered-By: Lasso 9 E: x C: a P: r Set-Cookie: _LassoSessionTracker_LEAP=bd9049a2-ff38-4e0b-9e7c-685a72d0a31e;expires=Wed, 13-Apr-2011 11:48:26 GMT;path=/ Content-Length: 42815 Vary: Accept-Encoding,User-Agent Content-Type: text/html; charset="UTF-8"

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft