Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose we create a link like this:

link = LinkCreate["mylink", LinkMode -> Listen]

How can we wait until this link gets connected to by another process, and time out if there's no incoming connection?

share|improve this question
What I'm really looking for is confirmation that the answer below is correct! – Szabolcs Jun 19 '14 at 1:25
Related W Community thread. – Szabolcs Jun 19 '14 at 18:58
I can absolutely certify that the answer is correct (although incomplete...there is no timeout that I'm aware of). I'll add a bit more technical detail to the Community thread, where you ask slightly different questions and make a misleading assertion. But the answer as I now see it here is correct without qualification. – John Fultz Jul 7 '14 at 1:46
up vote 2 down vote accepted

LinkActivate can be used for this. This Mathematica function is not documented, however the C version is.

From kernel 1, do

link = LinkCreate["mylink", LinkMode -> Listen]

LinkActivate[link] (* this will block and wait for an incoming connection *)

Now from kernel 2 (or another program, if using the C API), do

link = LinkConnect["mylink"]

(* will return immediately; at this point LinkActivate in kernel 1 also returns *)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.