Re: MathLink connection from Mac to UNIX
- To: mathgroup@smc.vnet.net
- Subject: [mg10728] Re: MathLink connection from Mac to UNIX
- From: kevinl@wolfram.com (Kevin Leuthold)
- Date: Mon, 2 Feb 1998 00:44:22 -0500
- Organization: Wolfram Research, Inc.
- References: <6as7bo$f4k@smc.vnet.net>
stupakov@slac.stanford.edu (Gennady Stupakov) writes: >I would like to run a program on a unix machine from Mathematica3.0 >that runs >on my Mac, using MathLink communication. The Mathematica book tells me >that it is possible (page 663): I have to start the unix program first >(say, addtwo -linkcreate) which returns the link (say, 3709@wilson), >and then go to the Mac and use >Install[LinkConnect["3709@wilson.slac.stanford.edu"]] >hoping that Mathematica will connects to the wilson computer (unix). >This however, does not happen. At this point the kernel on my Mac makes >an AppleTalk windows and asks me to find the program for connection in >the AppleTalk zones. That is not what I want. >My question is: how can tell Mathematica to use TCP/IP for this >connection? Presumably, I will also have to tell my login name and >password for telnet. Unfortunately, although the Mathematica book >claims that MathLink can work over TCP/IP, I did not find and example >how to do that. >Any help will be greatly appreciated. Gennady. Gennady, You can get MathLink to use TCP/IP on a Mac by using the LinkProtocol option. Before I give an example of how to do that, let me warn you about two bugs in Mathematica 3.0 that you will have to work around. (Note that you can always use the LinkProtocol option - it's just that TCP is the default on Unix, but not on the Mac, so using that option to get a TCP connection on Unix is redundant). (1) The LinkProtocol Option doesn't work with LinkConnect. Since LinkConnect is equivalent to LinkOpen[LinkMode -> Connect], you can use LinkOpen instead. (2) There is a bug in 3.0 MathLink for Macintosh in the domain name resolution that connecting to a link over the TCP protocol using the machine name of the other machine will not work - you must use the IP address instead. (Both of these bugs will be fixed in the next major release of Mathematica). So, to do what you want to do, instead of Install[LinkConnect["3709@wilson.slac.stanford.edu"]] you should do (assuming 100.100.10.5 is the IP address for wilson.slac.stanford.edu. Install[LinkOpen["3709@100.100.10.5", LinkMode -> Connect, LinkProtocol -> "TCP"]] Conversely, you can have the mac create the link and the Unix machine connect to it, by doing this: link = LinkCreate[LinkProtocol -> "TCP"] on your mac. This will give you a LinkObject with an IP address instead of a machine name because of bug #2 above. Let's say that the output of the above line is LinkObject["1025@100.100.10.4", 1, 1] Then on your Unix machine, you can do this: addtwo -linkconnect -linkname '1025@100.100.10.4" and finally on your Mac do this: link = Install[link] Finally, you should not have to use your login and password to make such a connection. If you were trying to launch a remote kernel from your mac, you would have to supply a login and password, but not in making a peer-to-peer connection as you're trying to do. I hope this helps. Kevin Leuthold MathLink Group Wolfram Research