Back to Opening Connections (hopen)

Interprocess Communication (IPC) · Opening Connections (hopen) · Practice Question

Open a Connection to Another Process

Sign in to track your progress

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 5001

Alternative Solution

h:hopen `:localhost:5001

Alternative Solution

h:hopen `::5001

Explanation

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.