| Customize Help

Hosting files on a MIL HTTP server

You can host files on the local computer using a MIL HTTP server. The HTTP server makes the contents of a specified folder (and its subfolders) readable using any HTTP/1.1-compatible web browser on a connected remote computer. If the folder contains valid HTML files, they will be viewable as a web page. To create a MIL HTTP server, you need to allocate a MIL HTTP server object in your MIL application using MobjAlloc() with M_HTTP_SERVER.

MIL HTTP servers are intended to be run on a segmented LAN that has no internet/WAN access; MIL HTTP servers offer no internal security mechanisms. When a MIL HTTP server is enabled, you should typically ensure that your network administrator configures your network to prevent incoming connections from the internet to the computer running your MIL application (and from any other devices on your network that do not need access). If this is not possible, at a minimum, you should block incoming connections from the internet to the listening port of the HTTP server. You can inquire which port is used for this purpose, using MobjInquire() with M_HTTP_PORT.

Using a MIL HTTP server within your MIL application is typically more convenient for simple file hosting than installing and configuring third-party server software. Additionally, allocating a MIL HTTP server within your MIL application ensures that the HTTP server only runs while your MIL application is active. Note that a MIL HTTP server is only capable of hosting files; it cannot execute programs or scripts (for example, using CGI or PHP). It is therefore not suitable for hosting complex websites.

While a MIL HTTP server is typically used to host the HTML and JavaScript files of a MILweb client application, it can also be used to host other web pages or types of files. You can allocate and use a MIL HTTP server regardless of whether MILweb server functionality is enabled for your application (and vice versa).

The following steps provide a typical methodology to host the contents of a folder with a MIL HTTP server:

  1. Allocate an HTTP server using MobjAlloc() with M_HTTP_SERVER.

  2. Set the full path to the folder (on the local computer) that contains the files and subfolders to host on the HTTP server, using MobjControl() with M_HTTP_ROOT_DIRECTORY.

    All files and subfolders in this folder will be readable by other computers on your network while the HTTP server is enabled. Therefore, you should typically ensure that there are no sensitive files in this folder (or its subfolders).

  3. Optionally, specify the listening port on which the HTTP server receives incoming connections, using MobjControl() with M_HTTP_PORT. This must be a port not used by any other application running on the local computer. The default port is 8080.

  4. Optionally, specify the web address (URL) that remote computers will use to access the HTTP server, using MobjControl() with M_HTTP_ADDRESS. This must consist of http://, followed by the domain name or local static IP address of the local computer (for example, or http://VisionController42).

    The default URL (http://localhost) is only accessible from a web browser running on the local computer.

    You must have administrator permissions on the local computer to make the HTTP server accessible to remote computers.

    If your local computer is running more than one HTTP server application (either multiple MIL HTTP servers, or other HTTP server software in addition to your MIL application), you must append to the URL a colon (:) followed by the listening port (for example,

  5. Start the MIL HTTP server using MobjControl() with M_HTTP_START.

Once you run your MIL application, you can access the hosted files using any web browser on a computer that has access to the HTTP server. To download a file from a MIL HTTP server, type the URL in the address bar of your web browser. The URL must include the path to the file, relative to the root directory specified using MobjControl() with M_HTTP_ROOT_DIRECTORY (for example,

If you are accessing the html files used for a web page, you only need to manually download the web page's entry point html file; your web browser will automatically download any additional required files. By convention, this file is usually named index.htm or index.html, but it can have any name.

Directory listing is not enabled for MIL HTTP servers; the HTTP server does not publish a list of available files and folders. Therefore, you must already know the path to the file to download it.