Hello, I’ve been going through a lot of tutorials, examples, Ect. On how to use sockets in python to create an online game.
I came up with this:
import socket
class World(DirectObject)
def __init__(self):
self.host = 'localhost'
self.port = '25565'
def open_socket(self):
self.server = socket.socket(socket.AF_INET,
socket.SOCK_STREAM)
self.server.bind((self.host,self.port))
self.server.listen(5)
def Run(self):
self.open_socket()
running = 1
id = 0
while running:
id +=1
c = Client(self.server.accept())
c.start()
When I run it, I get this error:
DirectStart: Starting the game.
Known pipe types:
wglGraphicsPipe
(all display modules loaded.)
Worked!
Traceback (most recent call last):
File "Blaze3D.py", line 238, in triggerStartAction
self.Run()
File "Blaze3D.py", line 249, in Run
self.open_socket()
File "Blaze3D.py", line 245, in open_socket
self.server.bind((self.host,self.port))
File "<string>", line 1, in bind
TypeError: an integer is required
:task(error): Exception occurred in PythonTask triggerStartAction
Traceback (most recent call last):
File "Blaze3D.py", line 655, in <module>
run()
File "C:\Users\Britany\Desktop\Panda3D\Panda3D-1.7.2\direct\showbase\ShowBase.py", line 2630, in run
self.taskMgr.run()
File "C:\Users\Britany\Desktop\Panda3D\Panda3D-1.7.2\direct\task\Task.py", line 502, in run
self.step()
File "C:\Users\Britany\Desktop\Panda3D\Panda3D-1.7.2\direct\task\Task.py", line 460, in step
self.mgr.poll()
File "Blaze3D.py", line 238, in triggerStartAction
self.Run()
File "Blaze3D.py", line 249, in Run
self.open_socket()
File "Blaze3D.py", line 245, in open_socket
self.server.bind((self.host,self.port))
File "<string>", line 1, in bind
TypeError: an integer is required
**** End of process output ****
Out of this,
I cannot seem to find the error.
Or even if this will work.
I’ve found a lot of unreliable sources,
Do you think this one is correct?
It’s nothing too big, Just something I can work with for now. I’ll be adding more to it later on, But i first have to know if this is going to work to accept other players.
Thanks for the help,
Luna