Local links
NetStreams reference
Note that this sample requires these versions of the
AXPack1 family components installed:
newObjects Pack1 core (version 2.4.1.3 or later)
NetStreams (version 1.0.0.4 or later)
Internet links
newObjects ActiveX Pack1
(ALP run-time library as separate download)
newObjects main site
code.newobjects.com
|
About this sample
This sample implements a simple WEB server. It uses the ALP
run-time library and more specifically the NetStreams components,
the COMScriptThread and a few other helper objects.
The implementation uses a background thread to run the main
HTTP server code. So, there are two script files:
http-srv.asp - controls the thread of the WEB server
http-srv-imp.vbs - implements the server (this runs within the
thread).
It serves only the resources in the httproot directory and only
a few file types. If you want you can change the source code and
add more functionality. The HTTP support is minimal just enough to
get it working. The code for the thread is very similar to the
other HTTP server sample where no threads are used (for Micro
Script Host only). The only
important difference is that here the code runs separately and
provides the main script (http-srv.asp) with access to the
listening socket so that it can interrupt the server and tell it
to stop when the user requests that.
The sample uses blocking sockets and serves the requests
sequentially. Therefore the resources should be small in order to
avoid long timeouts. Thus a WEB server implemented this way is
good only for local usage by no more than 3-4 clients.
How to implement something better? For that purpose you will
need to use sockets in non-blocking mode, check their state from
time to time and send little chunks of data through every
connection that must be served. It will be even better to start
several threads and serve more than one request at a time. Using
ActiveX Pack1 family (an alias for the ALP run-time library) this can be done in various ways
and will not need too much code to be written.
|