In this post I will show you part of the last experiments on sockets multiplexing. This has been added in Toro a couple or years ago, however, only now I could make an example that works. This is a simple example, i.e., a simple http server that prints a welcome message. To make it works, I spent the last month fixing bugs in the networking. Also, I fixed an important bug in the memory manager. In the following, I will show how socket multiplexing is used in the case of a http server. The code of the example can be found in tests/ToroHttp.pas. In this post, I am not going into details about how socket multiplexing works. I will try only to give a big picture.
Let's first discuss the code of ToroHttp.pas (see Figure 1). This is the main program. It defines the network handler, i.e., HttpHandler. Then, it sets the right methods, e.g., DoInit(), DoAccept().
| Figure 1. |
After that, the handler is registered by using SysRegisterNetworkService(). The kernel will execute the different methods. For example, the first method invoked will be HttpInit().
| Figure 2. |
![]() |
| Figure 3. |
In the Qemu VM, we see that the connection is received and then closed:
As I said before, I only explained some details about socket multiplexing. I used the http server as a running example. The whole example is hosted in toro repo so please fell free to clone it.
Matias Vara
