tsNet: New Networking Capabilities for LiveCode

by Charles Warwick on September 9, 2016 2 comments

Faster, Better Networking
Starting with the 8.1.0 DP3 release, LiveCode commercial editions include a new networking external, tsNet, that enhances the existing networking capabilities of LiveCode. tsNet utilises the curl networking library to provide a full suite of functions for both synchronous and asynchronous transfers using HTTP(S), FTP(S), SFTP and SMTP(S) protocols. This is good news for LiveCode developers as along with the support of new protocols, all transfer types can be performed in a non-blocking manner with callback support.

Wraps Existing Library
As well as providing a suite of commands and functions that provide comprehensive support for networking transfers, the tsNet external comes with a libUrl wrapper that provides existing scripts an immediate and automatic benefit.  From the DP3 release, any scripts that make use of the libURL Internet library will seamlessly be handled by the tsNet external.

Major Performance Boost
Apart from the obvious benefits of asynchronous transfers and additional protocols, tsNet brings a major performance boost to LiveCode’s networking toolkit. 
This performance increase is apparent in several ways: 

  1. tsNet is written as an external and fully implemented in C.  This provides a significant improvement over the existing libURL library which is written in LiveCode script.
  2. The increase in speed is immediately available to all existing scripts that use the Internet library without any changes to code.  While it may not be all that noticeable for very small files or over slower networks, transferring large files across a LAN really highlights this improvement.
  3. tsNet runs on a separate thread. This means that animations and other handlers can continue running while transfers are taking place, unlike the standard libURL library which processes all transfers on the LiveCode engine thread. The LiveCode engine is freed up to execute other handlers during large transfers.
  4. The asynchronous non-blocking capabilities of the tsNet external also provide significant improvement to the performance of LiveCode applications.

How Much Faster?
In a simple test of posting a binary file of approximately 114MB to a HTTP server across a local network (using a command such as `post tData to URL “http://www.domain.com/upload.php”`), LiveCode’s Monte Goulding saw a speed improvement in the order of 250x faster using the tsNet library compared to the standard libURL library!  Yes, 250 times faster, that is no misprint!

Kevin highlighted the real world example of an application that Todd Fabacher wrote in his keynote presentation at the recent LiveCode conference.  This application was taking 45 minutes to perform an initial load of data using 5000 HTTP POST requests.  With some very simple modifications to make it utilise tsNet’s asynchronous network functions, this time was reduced to 12 minutes.

Utilising tsNet’s asynchronous functions

For those who want to quickly see how to implement an asynchronous request complete with error checking, a simple example can be downloaded here.

As there is also a new range of commands for synchronous networking transfers as well, this stack highlights a few of these features.

Charles WarwicktsNet: New Networking Capabilities for LiveCode

Related Posts

Take a look at these posts

2 comments

Join the conversation
  • Chris - October 12, 2016 reply

    Do you support SSH?

    Thanks!

    Charles Warwick - October 15, 2016 reply

    Hi Chris,

    You can transfer files and issue file related commands via the SFTP protocol using tsNet, but there is no ability to directly login via SSH at this point in time.

Join the conversation

*