319
TIDE and Tibbo BASIC User Manual
©2000-2008 Tibbo Technology Inc.
If there is an incoming HTTP connection request, and if your application has no
HTTP sockets configured to accept this connection, then the system will still
respond with a reset.
This behavior allows your application to get away with fewer HTTP sockets. Here is
why. If all HTTP sockets are busy and your application sends out a reset, the
browser will show a "connection reset" message. If, however, your device does not
reply at all, the browser will wait, and resend its request later. Browsers are
"patient" -- they will typically try several times before giving up. If any HTTP
sockets are freed-up during this wait, the repeat request will be accepted and the
browser will get its page. Therefore, very few HTTP sockets can handle a large
number of page requests in a sequential manner and with few rejections.
Other differences
All incoming data is still stored in the TX buffer (yes, TX buffer). This data,
however, is not passed to your program but, instead, is interpreted as HTTP
request. This HTTP request must be properly formatted. The sock object supports
GET and POST commands.
at all and does not have be allocated any memory.
GET and POST commands can optionally contain "request variables". These are
stored into the VAR buffer from which your program can read them out later.
No
event is generated when the HTTP request string is
received into the RX buffer.
Once entire request has been received the socket prepares and starts to output
the reply. Your program has no control over this output until a BASIC code
fragment is encountered in the HTTP file. The
event
cannot be used as well.
When code fragment is encountered in the HTTP file control is passed to it and
then your program can perform desired action, i.e. generate some dynamic HTML
content, etc. When this fragment is entered, the
is automatically
set to the correct socket number.
Once HTTP reply has been sent to the client the socket will automatically close
the connection, as is a normal socket behavior for HTTP. A special property-
- allows you to change this default behavior and leave the
connection opened.
Including BASIC Code in HTTP Files
To create dynamic HTML pages, you include BASIC statements directly into the
HTML file. A fragment of BASIC code is included within "<? ?>" encapsulation, as
shown in the example below (for more info see
):
<!DOCTYPE HTML
public
"-//W3C//DTD W3 HTML//EN"
>
<HTML>
<BODY>
HELLO HTML WORLD!<br>
<?
'This is a BASIC code snippet. We can, for instance, send
something to the serial port
ser.num=
0
ser.setdata(
"HELLO SERIAL WORLD TOO!"
)
ser.send
?>
</BODY>
</HTML>
315
342
342
340
335
74