Re: Re: raw TCP/IP socket communication in mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg17656] Re: [mg17619] Re: raw TCP/IP socket communication in mathematica
- From: "Mitja Lakner" <mlakner at fagg.uni-lj.si>
- Date: Fri, 21 May 1999 03:37:41 -0400
- References: <Pine.GSU.4.05.9905041712540.21049-100000@flip.eecs.umich.edu> <7grica$e6h@smc.vnet.net> <199905180645.CAA20718@smc.vnet.net.>
- Sender: owner-wri-mathgroup at wolfram.com
Is there interface to Win sockets using mathlink? (MSVC 6.0) Mitja Lakner ----- Original Message ----- From: Daniel Reeves <dreeves at flip.eecs.umich.edu> To: mathgroup at smc.vnet.net Subject: [mg17656] [mg17619] Re: raw TCP/IP socket communication in mathematica > > I took paulh at wolfram's advice, and implented an interface to unix sockets > using mathlink. > > http://ai.eecs.umich.edu/people/dreeves/misc/math-sockets/ > > It includes a sample notebook that grabs an arbitrary webpage from the > internet and spits out the contents. About 4 lines ("link to socket > library", "connect to web site", "ask for web page", "receive response"). > > I still think raw TCP/IP communication should be part of the kernel. To > Jens's comment that it can't be because his windows box can't do it, I > have 2 responses: 1, his machine would fail to create any link to a > remote machine, "Raw" or otherwise. 2, Mathematica does not take a lowest > common denominator approach to operating system functionality, eg, piping > to external programs is supported in Mathematica even though it won't work > on some operating systems. > > So again I'd like to urge Wolfram developers to consider including this > functionality in the kernel. I'd like to see Mathematica become the > language of choice for things like "intelligent internet agents" (like > bidding agents for online auctions) and not having built-in ability to > send and receive data over the internet is a big enough hurdle to prevent > that from happening. Compiling/porting/etc something like what I've done > is a huge headache. But inside the kernel, this problem is already solved > -- there just needs to be an option to turn off enforcement of the > structured, mathlink-packet-based communication and use raw strings > instead. > > PS: When I first posted my message about my MASH thing, I accidentally > didn't have the source code (mash.c) visible. It's now there at > http://ai.eecs.umich.edu/people/dreeves/misc/mash/ > > Thanks, > Daniel > > -- -- -- -- -- -- -- -- -- -- -- -- > Daniel Reeves http://ai.eecs.umich.edu/people/dreeves/ > > "'Artificial Intelligence' ceases to be 'intelligent' as soon as it's > actually implemented." -- Uluc Saranli > > On 6 May 1999, P.J. Hinton wrote: > > > On Tue, 4 May 1999, Daniel Reeves wrote: > > > > > I think the ability to send and retrieve arbitrary strings over TCP > > > sockets is very important. The specific application I have in mind is > > > creating bidding agents that participate in an online auction (part of my > > > research on artificial intelligence for ecommerce). This type > > > of application is becoming more and more common and I think it's important > > > that Mathematica support communication with programs other than mathlink > > > compatible ones. Bots that gather data on the web is another example of > > > why this would be necessary. > > > > > > It should be straightforward to implement this in the kernel by having an > > > option for LinkConnect that says "Raw". Then all LinkWrite's and > > > LinkRead's would send and receive plain strings. > > > > Alternatively, you could build an installable MathLink binary that defines > > a top-level interface to your operating system's native socket API. That > > would be a highly reusable component that could be launched whenver > > needed. > > > > Below is an example of a top-level interface to the Unix system call > > uname(). You could create a MathLink template like this: > > > > :Begin: > > :Function: myuname > > :Pattern: SystemInformation[] > > :Arguments: {Null} > > :ArgumentTypes: Manual > > :ReturnType: Manual > > :End: > > > > and then the C code would look something like this: > > > > #include <sys/utsname.h> > > #include "mathlink.h" > > > > void myuname(void); > > > > void myuname(){ > > struct utsname unamedata; > > int retval; > > > > retval = uname(&unamedata); > > > > if(retval == 0){ > > MLPutFunction(stdlink, "List", 6); > > MLPutString(stdlink, unamedata.sysname); > > MLPutString(stdlink, unamedata.nodename); > > MLPutString(stdlink, unamedata.release); > > MLPutString(stdlink, unamedata.version); > > MLPutString(stdlink, unamedata.machine); > > MLPutString(stdlink, unamedata.domainname); > > } > > else{ > > MLPutSymbol(stdlink, "$Failed"); > > } > > > > return; > > } > > > > int main(int argc, char *argv[]){ > > return MLMain(argc, argv); > > } > > > > I can now get the result of uname from my installed function. > > > > In[1]:= Install["myuname`"] > > > > Out[1]= LinkObject['./myuname.exe', 1, 1] > > > > In[2]:= LinkPatterns[%1] > > > > Out[2]= {SystemInformation[]} > > > > In[3]:= SystemInformation[] > > > > Out[3]= {Linux, monon, 2.0.0, #1 Mon Jun 10 21:11:56 CDT 1996, i586, > > (none)} > > > > -- > > P.J. Hinton > > Mathematica Programming Group paulh at wolfram.com > > Wolfram Research, Inc. http://www.wolfram.com/~paulh/ > > > > >
- References:
- Re: raw TCP/IP socket communication in mathematica
- From: dreeves@flip.eecs.umich.edu (Daniel Reeves)
- Re: raw TCP/IP socket communication in mathematica