Using HTTP

The sock object can function as a HTTP server. This means that when certain conditions are met, individual sockets will switch into the HTTP mode and output the data in a style, consistent with the HTTP server functionality.

Certain BASIC information about the HTTP server has already been provided in WORKING WITH HTML.

When the socket is in the HTTP mode your program has no control over the received data (HTTP requests) and only sometimes has control over the transmitted data (HTTP reply).

In the simplest case the file returned to the web browser is static- a "fixed" HTML page, a graphic, or some other file. Processing of such a static file requires no intervention from your program whatsoever. Just setup the socket(s) to be able to accept HTTP requests and the sock object will take care of the rest.

More often than not, however, you have to create a dynamic HTML page. Dynamic pages include fragments of BASIC code. When the sock object encounters such a fragment in the file being sent to the browser, it executes the code. This code, in turn, performs some action, for example, generates and sends some dynamic data to the browser or jumps to the other place in the HTML file.

The HTTP server built into the sock object understands two request types- GET and POST. Both can carry "HTTP variables" that the server will extract and pass to the BASIC code.

Supported content (file) types

At the moment, the following file extensions (types) are explicitly supported:



Returned Content-Type


All platforms



All platforms



All platforms



All platforms



All platforms



All platforms



All platforms



32-bit platforms



32-bit platforms



32-bit platforms



32-bit platforms



32-bit platforms


HTML files may include executable Tibbo BASIC or Tibbo C code. This allows to create dynamic HTML output.

All other file types are always static and are sent to the browser "as is". There is, however, a method of programmatic generation of such files — see URL Substitution.

Some file types are only supported on 32-bit platforms. Platform type is listed on each platform's page.


Currently, the socket object can only access first 65534 bytes of each file, even if the actual file is larger! Make sure that all HTML files (and other files that will be returned by the built in server of your device) are not larger than 65534 bytes. This is not to be confused with the size of HTTP output generated by HTTP file. A very large output can be generated by a small HTML file (due to dynamic data generation)- and that is OK.

65534 is actually the size limitation for the compiled HTML file. When compiling your project, the TIDE will separate the static portion of the file from the Tibbo BASIC/C code fragments. Only the compiled file size matters.

File compression (32-bit platforms only)

On 32-bit platforms, files of all types except HTML can be attached to the project in .gz (compressed) form.

For example, rather then attaching picture.jpg you can compress this file and attach picture.jpg.gz. TiOS webserver will handle this correctly:

Whenever a browser requests picture.jpg, the server will first look for this file and, if not found, will also look for picture.jpg.gz. If the latter is found, the browser will output this file with "Content-Encoding: gzip" in the reply header.

Compressed HTML files are not supported. This is because HTML files can potentially include executable Tibbo BASIC or Tibbo C code. Therefore, TiOS must store such files in their original, uncompressed, form.