Course of Raku / Functional, concurrent, reactive, and web programming / Web programming / A simple HTTP server / Exercises

A hello server

Problem

Write a program that listens on 127.0.0.1 port 8080 and, in a loop, accepts connections — printing a client connected each time a client arrives. This is the shape of a real server, which keeps accepting clients rather than stopping after one.

Run this on your own machine and connect to 127.0.0.1:8080 (for example with a browser) to trigger it. Stop it with Ctrl-C.

Example

Each time a client connects, the program prints:

a client connected

Solution

See the solution

Course navigation

Responding to a request   |   Solution: A hello server