Interprocess Communication (IPC) · Opening Connections (hopen) · Practice Question
Demonstrate hopen Timeout Behaviour
Question
Demonstrate the timeout behaviour of hopen in practice.
Solution
On the server, instruct the process to sleep for 1000 seconds, so it can't respond to anything:
system"sleep 1000"On the client, attempt to connect with a 10-second timeout:
h:hopen (`::5001;10000)After 10 seconds, hopen gives up with:
'timeoutExplanation
system"sleep 1000" blocks the server entirely — q is single-threaded, so it can't service any handshake while stuck there.
The client's hopen waits only as long as its timeout allows — 10 seconds — then signals 'timeout. Without a timeout, it would wait the full 1000 seconds the server stays asleep.
This is why a timeout is worth passing whenever the target's responsiveness isn't guaranteed: it bounds how long the connecting side waits, even with no control over the other side.