Technical Note: Aloe Express Process Flow

While Aloe Express hides the complexity involved in receiving and responding requests, it is helpful to understand what's happening "under the hood."

The Server

All Aloe Express-based apps include an instance of the Server class (a subclass of the Xojo ServerSocket class), which is typically created as part of the app's Run event. The Server can then be configured. For example, you can specify the server's port, as well as the size of its pool of Request instances - maximum number of connections that can connect simultaneously, and the minimum number of sockets that should be available in the pool.

After configuring the Server instance, the application calls the Server's Start method. At this point, the server creates the initial pool of Request instances and begins listening for incoming requests. When a request is received, the Server assigns it to an available Request instance.


The Request class is a subclass of the Xojo TCPSocket class. It provides access to a request's headers, parameters, and other properties that are often needed to process a request.


Each request is assigned an instance of the Response class, which provides properties and methods for generating a response. You can specify a response's status code, headers, content, and more.


The RequestThread class is a subclass of the Xojo Thread class. When a request is ready to be processed (i.e. its DataAvailable even handler has fired), it is assigned to a RequestThread. This moves the request off of the main thread, preventing other requests from being blocked while the request is processed.

App RequestHandler

When a RequestThead's Run event fires, the Request is passed to the app's RequestHandler method for processing. As a developer, it's in the RequestHandler method that you customize your Aloe Express app. You can add logic that evaluates requests, routes them, and generate responses.

When the RequestHandler method is finished, the response is sent to the client, and the Request instance once again becomes available to process other requests.

© Copyright 2019 Tim Dietrich. Made with Xojo 2018r4 & Aloe Express 4.1.0.