Processing stream from tcp/ip

Paul Brennan's icon

Hi there,


I've got a stream of data coming in from a tcp/ip port using sadam.tcpClient. It's coming in as binary data, and based on the example, goes through itoa which converts to Unicode I believe. At that point I can print it, but I notice that the data stream isn't regular - it's made up of XML elements, and most print statements have one element in, but others have 2 3 or 4. I'm not sure what exactly triggers print in this context.

The XML structure is very simple and I have been using just regex to extract the couple of values (floats) that I'm interested in. But it's a nuisance to deal with the irregularity of the data. There's probably a much better way to process this stream but looking at the tutorials I'm a bit stuck at the moment. Any suggestions welcome.

Thanks, Paul

rjungemann's icon

You're in luck, the sadam package is now in the package manager, and contains objects for regular TCP and UDP networking. Node for Max is another option, which comes with Max as of the latest major release.

Paul Brennan's icon

Thank you - I'm already using sadam.tcpClient, see above, and it's working, I guess where I'm a bit stuck is what to do with the data I get from it, how best to parse it and process it. It's simple enough data, just two XML elements from which I want to derive two floats and use them to control a synth or soundscape of some kind (TBD). Maybe Node for Max would help with this?