MathLink supports two communication protocols on all platforms: TCPIP or shared memory. There are additional protocols supported on some systems only ("FileMap" and "Pipes" according to the docs).

I do not have much familiarity with MathLink's C language interface.

Question: Is the MathLink communication protocol user-customizable? Can MathLink be extended by users to use an alternative underlying communication protocol (example)?

  • $\begingroup$ I expect the answer to be "no", but it happened before that I asked such a question and I received a surprisingly positive answer. $\endgroup$
    – Szabolcs
    Jan 24, 2012 at 14:18
  • $\begingroup$ Seems like you could write a MathLink wrapper that tunneled over any kind of connection you like. Does that fit the parameters of your intent? $\endgroup$
    – sblom
    Jan 24, 2012 at 16:07
  • $\begingroup$ @sblom, that is a good point. I would assume it would. $\endgroup$
    – rcollyer
    Jan 24, 2012 at 16:13
  • $\begingroup$ The protocols are implemented in the .mlp files which are called from the main MathLink libraries (ml64i3 etc.), so in principle the answer is yes. However, the API and ABI by means of which these two MathLink components communicate is totally undocumented, so writing a new .mlp file is likely to be pretty much impossible without reverse-engineering both parts. Debug versions with symbols are included in the MathLink Developer Kit if you're feeling adventurous... $\endgroup$ Jan 31, 2012 at 22:12

1 Answer 1


Seems entirely possible. I'd start by writing a stub for each end whose entire purpose is to echo MathLink traffic over your custom channel. Without doing any measurement, my first guess would be that you should use the existing shared memory protocol for the stub to connect to the MathLink peer on either end.

As I think about it more, the stubs don't really even need to understand the MathLink protocol at all. If you use TCP/IP on either end, and you have a way to tunnel TCP/IP over your custom channel (a la SSH port forwarding), you're all set and don't have to write any code.

  • $\begingroup$ +1, for pointing out how to not write any code at all. $\endgroup$
    – rcollyer
    Jan 24, 2012 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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