TCPIP object for Max 5?

May 26, 2009 at 9:58pm

TCPIP object for Max 5?

Hello,
I’m looking for a single object that will give me the equivalent of a two way TCP/IP telnet socket. (not UDP)

The current objects I’m trying [netsend] and [netreceive], don’t seem to allow for an acknowledgement response via the same socket used to send data (although establishing a connection and sending data works great).

I’ve found the older [nottcp] and [tcpClient] objects who’s documentation confirms the functionality I’m looking for…
but either I’m really lame or they aren’t compatible with Max5.

Help?

Thanks,
D

#44103
May 26, 2009 at 10:44pm

Check out the mxj (java) versions, e.g. mxj net.tcp.send.

David

#158461
May 26, 2009 at 11:44pm

I’ve tried the MXJ versions as well and, unless I’m missing something, [net.tcp.send] will echo a successful transmission but it doesn’t output any responses from the receiving party via the same TCP socket.

-D

#158462
May 27, 2009 at 4:49pm

In a last ditch effort I just tried a few of the [shell] objects that are floating around, in hopes that invoking a Telnet session would give me the responses that I need.

It returns the escape character response but nothing more after that.
A command like ‘top’ though, that continuously refreshes its output seems to work fine through the shell object.

I am finding it really hard to believe that with all the crazy networking people do with Max, a simple socket send/response functionality is this hard to come by…

-D

#158463
Jun 2, 2009 at 1:02am

Throwing this out there again…

I’m totally dead in the water without a two-way TCP/IP socket object.

The frustrating part is that one seems to exist for Max4 here:

http://www.opendragon.com/Pages/MaxObjects.shtml

but nowhere for Max 5.

-d

#158464
Aug 27, 2009 at 12:09am

Throwing this out there again as it’s been a while.

Anyone found anything that enables two-way send/response via a tcp socket for MAX 5?

-d

#158465
Aug 27, 2009 at 1:52am

You could almost certainly do it in Jython, either using the native libraries or calling down into Java. I knocked up a UDP transfer thing in a few minutes; TCP shouldn’t be too much more difficult.

http://www.loadbang.net/space/Software/net.loadbang.jython

(Pay no attention to the old Max4 screen shots; it all works fine in Max5.)

#158466
Aug 27, 2009 at 7:21am

its realy a shame, that nobody is able to get a telnet connection to work Sad
i also tested all java and shell objects.
sending was not the problem (with java), but did not get receiving to work.

i also tryed to search for some java telnet code.
but i did not have enough programming knowledge to make a max java object.

perhaps some java guru can give us a hint !

#158467
Nov 4, 2009 at 11:37am

Use two ports?

I’ve set-up something using two way communication between max/msp and visual basic 6.

I’m using one netsend connecting to winsock in vb6 on one port and another winsock in vb6 connecting to netreceive on another port to enable two way communication.

Yeah it’s a bit awkward, but it works

mxj crashes max as soon as i put it in a patch, dunno if that’s better

#158468
Nov 4, 2009 at 5:26pm

Two separate ports will not work for my application.

I am trying to communicate with hardware that listens for a Telnet style socket connection on a single port, and replies back down that same socket.

There are objects for earlier versions of max that offer this function, but nothing for Max5 yet.

#158469
Nov 4, 2009 at 5:34pm
Turbovolv wrote on Wed, 04 November 2009 10:26
There are objects for earlier versions of max that offer this function, but nothing for Max5 yet.

This isn’t a Max5 issue – it’s a code format/universal binary issue. The objects you point to are CFM externals (rather than .mxo universal binarys). Have you thought about emailing the developer to see if they can update them to the new format?

Most Max 4 objects that are .mxo files will run fine in Max5.

Regards

Alex

#158470
Nov 4, 2009 at 5:46pm

I didn’t mean to imply that it was a Max 5 issue, I was just citing examples of the existing objects so that people reading this understand exactly what I need and that it has been done before.

Yep, I’ve emailed him and he even sent me the source code.
He has plans to update it but it’s a fair amount of work and is on the back burner for now.

-D

#158471
Jun 9, 2010 at 3:28pm

Turbovolv, curious if you made any progress with the TCP external. (mired in telnet hell right now myself)

#158472
Jun 9, 2010 at 7:43pm

what about jit.net.send / jit.net.recv? Don’t they do exactly this?

#158473
Jun 24, 2010 at 5:26pm

@ Scott F.
No, still haven’t found a solution for this, and am still in disbelief that it’s not a functionality in higher demand.
Glad you’re on the prowl too though.

@ seejayjames
As stated in the first couple posts, the current net.send / net.receive objects (and similar) don’t output any responses from the remote receiving party via the same TCP socket.
That was true a year ago, and I think it is still true today.

-D

#158474
Oct 6, 2010 at 1:07am

Ping! Any more movement on this front? I’d love to have a proper two way TCP socket.

#158475
Oct 7, 2010 at 7:35pm

I am also looking for this functionality. For now I have gotten around it by using netcat through aka.shell – I send it the symbol “echo YOUR_COMMAND_HERE | nc IP_ADDRESS PORT”, then I get any immediate response out the outlet of aka.shell. An example message would be “echo K? 11, | nc 192.178.1.6 7124″.

It seems to be necessary to pipe it ( that’s the | ) from ‘echo’ to do this. It then closes the socket right away, so you don’t get any following messages that are delayed, but you do get whatever is the immediate reply. It still does not leave the socket open, but its better than nothing. Netcat is included in OS X i think, unless i just happened to have it from some other installation, which is unlikely.

Additionally, I found that the netsend object contained in the UBCToolbox (0.94 for mac, I think you have to go back to v 0.92 to get these objects for windows) do have part of the functionality we are all looking for and sort of work in Max 5 – it leaves the socket open, but will not get replies back on the same socket. And, if you try to connect to a wrong IP address (ie one that does not exist/give a reply) in Max 5, Max just up and crashes. For this reason I had to scrap using them. They were a step in the right direction, but the development I’m doing (an end user app) can not tolerate such a thing!

#158476
Oct 7, 2010 at 7:47pm

Oh and you can easily create these messages for aka.shell using a sprintf like this:
[sprintf symout echo %s | nc %s %i]
which gives you inlets for message, IP address and port respectively and outputs as a symbol rather than a list so that max won’t try to reformat the numbers, spaces, commas and other punctuation.

#158477
Oct 9, 2010 at 2:48am

Cool, thanks.
That is a great little workaround that will at least get me going with the functionality I want on the Max end.

Yes, if only the the socket could stay open so I’m informed when something changes on the other end without having to ask… the puzzle would be complete.

Too bad netcat doesn’t support keep-alive when it’s in client mode, or it just might do the trick.

And thanks for turning me on to the UBCToolbox. I’ll keep an eye on that.

Cheers,
D

#158478
Oct 9, 2010 at 3:36am

glad it was helpful! It took me a while to figure this out – had to look at the apple developer docs pointed to in the aka.shell help patch to get the idea to try using echo.

Watch out for this though: if you try to connect to a non-existent IP with netcat through aka.shell, max will lock up for something like 15-30 seconds. Max will eventually come back, so don’t force quit if you have any unsaved changes. Probably this is the timeout time for netcat to return that it has not found that IP – I’m was trying to make that time shorter with arguments to netcat, but was not successful in a quick attempt.

#158479
Oct 29, 2010 at 8:08pm

So I’ve been working on a Java TCP client that does a persistent socket connection. Trouble is, I don’t know java!

I’ve managed to get it writing to the server nicely and I’ve made a decent interface to Max-land. But I cannot figure out how to read the server’s replies without hanging max. So this solves half the problem – sending the messages on one socket – but does not solve the getting back part.

Should it happen in a separate thread so as not to hang max? I am trying in the code to do what all the simple java tcp client examples online do for reading back, but it just hangs max every time. If anyone has any ideas that would be fantastic – I think it would be great to get this sort of thing working.

I’m attaching the java class I have so far and source code and a help patch that describes how to use it.

cheers,
Arvid

#158480
Oct 29, 2010 at 9:19pm

OK – I got it to work! This version should both send and read lines (when polled) on a single, persistent tcp socket.

I spawned a new thread to wait for the read-back. Seems to work ok here, but your milage may vary. Tested only on Mac so far, but will test on windows soon. It might be sort of a mess, but here it is anyway. Hope it works for you!

#158481
Nov 1, 2010 at 3:08pm

oops last one was missing a file if you didn’t recompile – here it is again – no other changes yet

#158482
Nov 1, 2010 at 9:47pm

New version 0.3 of tcpClient mxj:

Now behaves better when connections closed or socket closed by server
and also hangs for only 4 seconds if you try to connect to a wrong IP address (thanks to an article by David Reilly for the TimedSocket class) http://www.javaworld.com/jw-09-1999/jw-09-timeout.html
New messages for closed connections, trying to send without a connection, etc, rather than just crytic java errors in the Max window – so now you can act on those events in your patch.

As usual, put all files in your Cycling ’74/java/classes folder and type “mxj tcpClient” in a new object box. Supports attributes in object box: @address and @port.

#158483
Dec 9, 2010 at 6:24pm

New version 0.4 of the tcpClient mxj:

behaves even better when connections closed or socket closed by server
user setable connection attempt timeout
more and better status messages

cheers,
Arvid

#158484
Dec 30, 2010 at 5:51pm

Apparently I’m just talking to myself here, but looks like there are a few downloads, so I’ll post the newest version with attributes for tuning on or off Nagle’s Algorithm and for setting line endings to either n (newline) or rn (carriage-return newline).

Happy new year!

#158485
Jan 10, 2011 at 8:01pm

Somehow, my email notifications were turned off for this thread… so I’m sorry that you were talking to yourself for a while. Heh.

Anyway, this is all a pleasant surprise for the new year.
Now I’ve gotta find the time to play with it.

I’ll keep you posted.
Cheers,
Dan

#158486
Jan 10, 2011 at 10:26pm

Thanks, this is really awesome – I needed it for something a few years ago but it will serve me well in the future I am sure!

#158487
Apr 8, 2011 at 1:52pm

Arvid, I just wanted to thank you for this brilliant bit of work – it’s saved me a huge amount of trouble with a patch I needed to create in a hurry. Keep up the good work.

Tom

#158488
Apr 23, 2011 at 10:59pm

Wow, this totally works! I’ve been needing something like this for a while. Great work!

#158489
Apr 23, 2011 at 11:16pm

thanks :) glad its useful. Here’s a link to my webpage for the object: http://arvidtp.net/sw/max.php where the latest version will be if I update it in the future – as of this posting it’s still the same version I last posted here.

#158490
Mar 28, 2012 at 4:11pm

thankyou Arvid. keep us updated here please!!!

#158491

You must be logged in to reply to this topic.