WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-18-2012, 02:34 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

A couple things to note:
  • viznet currently uses UDP sockets for communication, not TCP. So there is no actual connection taking place. As long as the server address exists, it will report a successful "connection".
  • Network message events are triggered during the main update loop, not asynchronously. So if you are blocking the main thread, then you won't be receiving any network events.

I'd recommend looking into the Python Twisted library. It supports much more advanced networking features.

However, you can perform a blocking handshake by manually updating the network events in a while loop. Here is a minimal example:

Server code:
Code:
import viz
import viznet
viz.go()

HANDSHAKE = viznet.id('ConnectHandshake')

viznet.server.start()

# Perform handshake with clients
def onStartClient(e):
	viznet.server.sendClient(e.sender,HANDSHAKE)
viz.callback(viznet.CLIENT_CONNECT_EVENT,onStartClient)
Client code:
Code:
import viz
import viznet
import vizact
viz.go()

SERVER = 'MASTER'

HANDSHAKE = viznet.id('ConnectHandshake')

def ConnectServer(server,timeout=2.0):
	d = viz.Data(connected=False)
	if viznet.client.connect(server):
		def _handshake(e):
			d.connected = True
		cb = vizact.addCallback(HANDSHAKE,_handshake)
		expire = viz.tick() + timeout
		while not d.connected and viz.tick() < expire:
			viz.waitTime(0.1)
			viz.update(viz.UPDATE_NETWORK)
		cb.remove()
	return d.connected

if ConnectServer(SERVER):
	print 'Connected'
else:
	print 'Not Connected'
Hope that is helpful.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Connection problems from MotionBuilder to PPT nachac Precision Position Tracker (PPT) 2 07-27-2010 08:29 AM
problems nagivating around ruby21 Vizard 2 05-18-2010 03:22 PM
Problems loading WRL file DrunkenBrit Vizard 2 01-29-2009 12:58 AM
Problems Importing VRML Files oscar Vizard 4 10-13-2004 05:42 PM
Problems with lighting in 2.0 murm Vizard 6 04-21-2004 09:59 AM


All times are GMT -7. The time now is 01:54 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC