Course of Raku / Functional, concurrent, reactive, and web programming / Web programming / Making remote connections / Exercises
Connect to a host
Problem
Try to open a TCP socket to example.com on port
80, but guard the attempt with try so a
failure does not crash the program. If the connection succeeds, print
connected to example.com and close the socket; otherwise
print could not connect to example.com.
This exercise needs a working network connection to actually connect.
Example
When the connection succeeds, the program prints:
connected to example.com