Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
3  
What I'm really looking for is confirmation that the answer below is correct! –  Szabolcs Jun 19 at 1:25
    
Related W Community thread. –  Szabolcs Jun 19 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 at 1:46

1 Answer 1

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"]

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

Your Answer

 
discard

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.