Interprocess Communication (IPC) · Opening Connections (hopen) · Practice Question
Open a Connection to Another Process
Question
With the server listening on port 5001 and the client listening on port 5002 (both on the same machine), how can the client open a connection to the server?
Solution
h:hopen 5001Alternative Solution
h:hopen `:localhost:5001Alternative Solution
h:hopen `::5001Explanation
hopen opens a TCP connection and returns a handle — an integer used afterwards to send requests over it.
All three forms target the same machine, just with varying explicitness: a bare port number (5001) implies local; `:localhost:5001 names the host directly; `::5001 is the idiomatic empty-host shorthand for "this machine."
The resulting handle h is then used to send messages — h "..." for sync, neg[h] "..." for async.