[PD] Python socket to PD

joseph moore joseph_moore_ at hotmail.com
Tue Aug 10 22:48:53 CEST 2004


Hello list,
How should one go about sending information (in this case text) from Python 
to PD.  I know about the Python objects for PD but I want to have the Python 
script be able to run outside PD and with with a wxPython GUI.  So, right 
now I'm just trying to send a simple text message from Python to PD.  I have 
a netreceive connected to port 50007 and am running the following Python:

import sys
from socket import *
serverHost = 'localhost'
serverPort = 50007

message = ['hello PD']
if len(sys.argv) > 1:
	serverHost = sys.argv[1]
	if len(sys.argv) > 2:
			message = sys.argv[2:]

sockobj = socket(AF_INET, SOCK_STREAM)
sockobj.connect((serverHost, serverPort))

for line in message:
	sockobj.send(line)
	data = sockobj.recv(1024)
	print 'Client received', data
sockobj.close()

This is a little OT but I would appreciate help none the less ; )

best,
Joe(mediocre Python programmer trying to get better)

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/





More information about the Pd-list mailing list