python to max udpreceive

tomaso's icon

hello people...

i try to make python and max msp communicate through simple udpsend and receive objects on max..

this is my python script:
##################################
from socket import *

host = "localhost"
port = 20000
buf = 1024
addr = (host, port)

UDPSock = socket(AF_INET,SOCK_DGRAM)

def_msg = "===Enter message to send to server===";
print "n",def_msg

while (1):
    data = raw_input('>> ')
    if not data:
        break
    else:
        if(UDPSock.sendto(data,addr)):
            print "Sending message '",data,"'....."

# Close socket
UDPSock.close()

###################################################

I use this script to send data to udpreceive object in maxmsp...

the problem is that when i run the script from python, maxmsp prints:

net.recv.udp: OSC packet size (1) not a multiple of bytes: dropping

i tried various types of messages and the only thing that changed was the OSC packet size()

Whats the problem here? And why maxmsp reads osc, while i send simple udp messages?

im not very experienced in scripting so its very difficult for me to understand OSC so i try to use simple udp messages...

Philippe Montemont's icon
tomaso's icon

i tried the argument CNMAT HTH in udpreceive object...

i connected it with a print oblect and it prints:

Full packet 2 80707376

I understand that this is the packet information but how can i receive the message it self on the max patch?

Sorry maybe its obvious, but OSC is very difficult and there is no simple tutorials to learn it....

volker böhm's icon

On 05 Nov 2007, at 17:57, tom wrote:
>
> I understand that this is the packet information but how can i
> receive the message it self on the max patch?
>
> Sorry maybe its obvious, but OSC is very difficult and there is no
> simple tutorials to learn it....

no need for osc if you simply use [mxj net.udp.recv @port 20000].
works fine with your script.

volker.

mzed's icon

Quote: tomaso wrote on Mon, 05 November 2007 08:57
----------------------------------------------------
> i tried the argument CNMAT HTH in udpreceive object...
>
> i connected it with a print oblect and it prints:
>
> Full packet 2 80707376
>
> I understand that this is the packet information but how can i receive the message it self on the max patch?
>
> Sorry maybe its obvious, but OSC is very difficult and there is no simple tutorials to learn it....
>
>
----------------------------------------------------
Connect it to an OpenSoundControl object which you've downloaded from here:

mz

tomaso's icon

i connected udpreceive CNMAT HTH oblect with opensoundcontrol object,
but i can't find a way to receive the message...

it works with mxj.net.udp, but maybe i have to start learning osc
osc documentation doesnt help much..you have to be experienced to understand...

any suggestions on learning osc?