317
TIDE and Tibbo BASIC User Manual
©2000-2008 Tibbo Technology Inc.
Notice, that in most cases you will need to reserve more than one
socket for HTTP. The HTTP server may need to service multiple
requests from different computers at the same time. Even for a single
computer and a single HTML page, more than one socket may be
needed. For example, if your HTML page contains a picture, the
browser will establish two parallel connections to the sock object- one
to get the HTML page itself, another one- to get the picture. We
recommend that you reserve 4-8 sockets for the HTTP. It is better to
have less buffer memory for each HTTP sockets than to have fewer
HTTP sockets!
Setting the Socket for HTTP
How to set the socket for HTTP
Apart from assigning some memory to the TX, RX, and VAR buffers, the following
needs to be done to make the socket work in HTTP mode:
The protocol must be TCP (
= 1- PL_SOCK_PROTOCOL_TCP).
The socket must be open for incoming connections (typically, from anybody:
= 3- PL_SOCK_INCONMODE_ANY_IP_ANY_PORT).
Reconnects should not be enabled- this is counter-productive for HTTP (
= 0- PL_SOCK_RECONMODE_0). Reconnects are disabled by
default so just leave it this way.
Correct listening HTTP port must be set. Default HTTP port on all servers is 80 (
="80").
In the previous topic, we have already explained that your system should reserve
several HTTP sockets. Here is a possible initialization example:
dim
f
as
byte
...
'setup for other sockets, etc.
'setup sockets 8-15 for HTTP
for
f=
8
to
15
sock.num=f
sock.protocol= PL_SOCK_PROTOCOL_TCP
sock.inconmode= PL_SOCK_INCONMODE_ANY_IP_ANY_PORT
sock.httpportlist=
"80"
next
f
....
To make sure that the HTTP is working you can create and add to the project a
simple static HTTP file. Call this file <index.html>- this is a default file that will be
called if no specific file is requested by GET or POST. Here is a static file example:
345
338
345
335