socket connections

Hey,

I want to build in Connections into my program. The problem is the time it takes to connect to a host and receive data. Heres an example

>>> import urllib2, time
>>> def getTime(func):
	x = time.clock()
	func ()
	y = time.clock()
	print "TIME:", y-x

	
>>> def getHtml():
	data = urllib2.urlopen("http://www.panda3d.org/")
	html = data.read(1024)

	
>>> getTime(getHtml)
TIME: 0.395495495861

When I do this every time, in a frame my game will almost crash. Usually it takes 0.01 secs but not 0.4. Now what should I do? Is this method faster: panda3d.org/manual/index.php/C … Connection
But I didnt realy understand it well. When a client connects to a server with an UDPsock and send something like hello world, my name is localhost. Can the server send something back to the socket like Hello localhost! . I have never worked with udp before. And is there a better tutorial for that panda3d connection thing?

Edit: is it a possibility to use threading?

Ah, ok, I solved it. I just have to add a new task! Tasks are parralel