Forums > Dev

Problem with UDP

December 11, 2007 | 8:12 am

Hi all,

I am trying to send messages to max by UDP from a C++ program. I tried to send a string from a char buffer[256]. However, I received errors such as :

1) net.recv.udp: OSC packet size(19) not a multiple of 4 bytes: dropping or
2) OSC Bad message name string: DataAfterAlignedString: Unreasonably long sting Dropping entire message.

How can I resolve this error?

Also, is there any other way i can communicate betw. a C++ program and a MAX patch?

I would greatly appreciate some advice. Thanks in advance :P


December 11, 2007 | 10:56 am

Hi,

Udp communication in max is based on the OpenSoundControl standard.

http://www.cnmat.berkeley.edu/OpenSoundControl/OSC-spec.html

A tip might be to use the udpsend object to send data to your program and check the received bytes to see how data is formatted by max. Format the data you send to max the same way.

For example if you input a list starting with a symbol to udpsend, you’ll see that the first element is interpreted as osc address, then there is the comma, then the characters indicating the types of the remaining elements of the list, then the remaining elements themselves.

For example if I input "ding ja 45 e", the bytes look like this:

100 (d) 105 (i) 110 (n) 103 (g)
0 (*) 0 (*) 0 (*) 0 (*)
44 (,) 115 (s) 105 (i) 115 (s)
0 (*) 0 (*) 0 (*) 0 (*)
106 (j) 97 (a) 0 (*) 0 (*)
0 (*) 0 (*) 0 (*) 45 (-)
101 (e) 0 (*) 0 (*) 0 (*)
0 (*) 0 (*) 0 (*) 0 (*)

Note how every argument is padded with zero’s depending on the argument type.

Hth,
Mattijs


December 11, 2007 | 7:25 pm

Quote: tiutababo wrote on Tue, 11 December 2007 00:12
—————————————————-
> Hi all,
>
> I am trying to send messages to max by UDP from a C++ program. I tried to send a string from a char buffer[256]. However, I received errors such as :
>
> 1) net.recv.udp: OSC packet size(19) not a multiple of 4 bytes: dropping or
> 2) OSC Bad message name string: DataAfterAlignedString: Unreasonably long sting Dropping entire message.
>
> How can I resolve this error?
>
> Also, is there any other way i can communicate betw. a C++ program and a MAX patch?
>
> I would greatly appreciate some advice. Thanks in advance :P
—————————————————-

Ross Bencina has made an implementation of OSC in C++ here:

http://www.audiomulch.com/~rossb/code/oscpack/

mz


December 12, 2007 | 5:10 am

Thanks for your replies.

I’ve tried udpsend using max. However, it seems to work fine… returning just a string on C++ instead of the OSC format. strange…


December 12, 2007 | 5:11 am

http://www.audiomulch.com/~rossb/code/oscpack/

I’ve tried to compile this in visual C++ 6.0. However, i keep getting errors.


December 12, 2007 | 9:18 am

btw, I’m moving this topic to the dev forum


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