Forums > MaxMSP

TCPIP object for Max 5?

May 26 2009 | 9:58 pm

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.



May 26 2009 | 10:44 pm

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


May 26 2009 | 11:44 pm

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.


May 27 2009 | 4:49 pm

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…


Jun 02 2009 | 1:02 am

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.


Aug 27 2009 | 12:09 am

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?


Aug 27 2009 | 1:52 am

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.)

Aug 27 2009 | 7:21 am

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 !

Nov 04 2009 | 11:37 am

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

Nov 04 2009 | 5:26 pm

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.

Nov 04 2009 | 5:34 pm
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.



Nov 04 2009 | 5:46 pm

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.


Jun 09 2010 | 3:28 pm

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

Jun 09 2010 | 7:43 pm

what about / Don’t they do exactly this?

Jun 24 2010 | 5:26 pm

@ 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.


Oct 06 2010 | 1:07 am

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

Oct 07 2010 | 7:35 pm

I am also looking for this functionality. For now I have gotten around it by using netcat through – I send it the symbol "echo YOUR_COMMAND_HERE | nc IP_ADDRESS PORT", then I get any immediate response out the outlet of An example message would be "echo K? 11, | nc 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!

Oct 07 2010 | 7:47 pm

Oh and you can easily create these messages for 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.

Oct 09 2010 | 2:48 am

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.


Oct 09 2010 | 3:36 am

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 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, 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.

Oct 29 2010 | 8:08 pm

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.


Oct 29 2010 | 9:19 pm

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!

Nov 01 2010 | 3:08 pm

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

Nov 01 2010 | 9:47 pm

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)
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.

Dec 09 2010 | 6:24 pm

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


Dec 30 2010 | 5:51 pm

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!

Jan 10 2011 | 8:01 pm

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.

Jan 10 2011 | 10:26 pm

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!

Apr 08 2011 | 1:52 pm

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.


Apr 23 2011 | 10:59 pm

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

Apr 23 2011 | 11:16 pm

thanks :) glad its useful. Here’s a link to my webpage for the object: 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.

Mar 28 2012 | 4:11 pm

thankyou Arvid. keep us updated here please!!!

Viewing 32 posts - 1 through 32 (of 32 total)

Forums > MaxMSP