I'm trying to use a multiplayer module called PodSixNet to use in one of my games, but I get an error in assyncore.py
when trying to run the client. However, the server works flawlessly. I developed simple test client and server programs, but I still get the same error when I run the client. Here are my client and server programs respectively:
import PodSixNet, time
from PodSixNet.Connection import ConnectionListener, connection
from time import sleep
class MyNetworkListener(ConnectionListener):
connection.Connect()
def Network(self, data):
print data
gui = MyPlayerListener()
while 1:
connection.Pump()
gui.Pump()
.
import PodSixNet, time
from time import sleep
from PodSixNet.Channel import Channel
from PodSixNet.Server import Server
class ClientChannel(Channel):
def Network(self, data):
print data
class MyServer(Server):
channelClass = ClientChannel
def Connected(self, channel, addr):
print "new connection:", channel
myserver = MyServer()
while True:
myserver.Pump()
sleep(0.0001)
And here is the error I'm returned when I run the client:
Traceback (most recent call last):
File "C:\Users\Matt\Desktop\The 37th Battalion\PodSixNet Tests\client.py", line 5, in <module>
class MyNetworkListener(ConnectionListener):
File "C:\Users\Matt\Desktop\The 37th Battalion\PodSixNet Tests\client.py", line 7, in MyNetworkListener
connection.Connect()
File "C:\Python27\lib\asyncore.py", line 418, in __getattr__
retattr = getattr(self.socket, attr)
File "C:\Python27\lib\asyncore.py", line 418, in __getattr__
retattr = getattr(self.socket, attr)
File "C:\Python27\lib\asyncore.py", line 418, in __getattr__
retattr = getattr(self.socket, attr)
File "C:\Python27\lib\asyncore.py", line 418, in __getattr__
retattr = getattr(self.socket, attr)
This error continues until I reach maximum recursion depth. Help would be greatly appreciated.
Thanks, David
First, you have to tell the server which port it should listen on:
server.py
import PodSixNet, time
from time import sleep
from PodSixNet.Channel import Channel
from PodSixNet.Server import Server
class ClientChannel(Channel):
def Network(self, data):
print data
class MyServer(Server):
channelClass = ClientChannel
def __init__(self, *args, **kwargs):
Server.__init__(self, *args, **kwargs)
def Connected(self, channel, addr):
print "new connection:", channel
# use the localaddr keyword to tell the server to listen on port 1337
myserver = MyServer(localaddr=('localhost', 1337))
while True:
myserver.Pump()
sleep(0.0001)
Then, the client has to connect to this port:
client.py
import PodSixNet, time
from PodSixNet.Connection import ConnectionListener, connection
from time import sleep
class MyNetworkListener(ConnectionListener):
def __init__(self, host, port):
self.Connect((host, port))
def Network(self, data):
print data
# tell the client which server to connect to
gui = MyNetworkListener('localhost', 1337)
while 1:
connection.Pump()
gui.Pump()
You don't have to call Connect()
on connection
, but on the ConnectionListener
instance.