TCPIP object for Max 5?

Turbovolv's icon

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

David Beaudry's icon

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

David

Turbovolv's icon

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

Turbovolv's icon

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

Turbovolv's icon

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:

but nowhere for Max 5.

-d

Turbovolv's icon

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

nick rothwell | project cassiel's icon

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.

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

vguy's icon

its realy a shame, that nobody is able to get a telnet connection to work
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 !

tdtlot's icon

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

Turbovolv's icon

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.

AlexHarker's icon

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

Turbovolv's icon

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

Scott Fitzgerald's icon

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

seejayjames's icon

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

Turbovolv's icon

@ 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

Sasha Harris-Cronin's icon

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

Arvid Tomayko's icon

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!

Arvid Tomayko's icon

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.

Turbovolv's icon

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

Arvid Tomayko's icon

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.

Arvid Tomayko's icon

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

1312.tcpClient_atp_2010-10-29.zip
zip
Arvid Tomayko's icon

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!

1313.tcpClient_atp_2010-10-29b.zip
zip
Arvid Tomayko's icon

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

1321.tcpClient_atp_2010-11-01a.zip
zip
Arvid Tomayko's icon

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.

1323.tcpClient_atp_0.3_2010-11-01.zip
zip
Arvid Tomayko's icon

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

1515.tcpClientatp0.420101209.zip
zip
Arvid Tomayko's icon

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!

1613.tcpClientatp0.520101230.zip
zip
Turbovolv's icon

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

i@seanstevens.com's icon

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!

tom w's icon

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

jromney's icon

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

Arvid Tomayko's icon

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.

umma08's icon

thankyou Arvid. keep us updated here please!!!

admant's icon

Hello,
just to say thank you to Arvid because his job with tcp is very useful. It works with Telnet protocol and max like any other.

Antonio