Problem with UDP

tiutababo's icon

tiutababo

12月 11 2007 | 8: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

Mattijs's icon

Mattijs

12月 11 2007 | 10:56 午前

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

mzed's icon

mzed

12月 11 2007 | 7:25 午後

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:

mz

tiutababo's icon

tiutababo

12月 12 2007 | 5:10 午前

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

tiutababo's icon

tiutababo

12月 12 2007 | 5:11 午前

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

Mattijs's icon

Mattijs

12月 12 2007 | 9:18 午前

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

pli fred's icon

pli fred

8月 30 2024 | 6:46 午前

Hi all,

I only see the error message of 'DataAfterAlignedString: Unreasonably long string' when i send udp osc message to max.