Multi. Client handling

Hi everyone again:P Here is some code for you newbies like me that want to use networking with your games, its simple and down the core of the program with a little chat pro-app. It just shows how a server can handle more then one client. You can open the client setup as much as you want.

Also for client put in your ipaddress (open cmd and type in ipconfig if you dont know it). If it sucks, then sorry lmao XD


import SocketServer

class EchoRequestHandler(SocketServer.BaseRequestHandler):
  def setup(self):
    print self.client_address, 'connected!'

  def handle(self):
    while 1:
      data = self.request.recv(1024)
      print data
      if data.strip() == 'bye':

  def finish(self):
    print self.client_address, 'disconnected!'

#server host is a tuple ('host', port)
server = SocketServer.ThreadingTCPServer(('', 5000), EchoRequestHandler)


import socket

tcpstock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
tcpstock.connect (("YourIpAddress", 5000))

while (1):
  data2 = raw_input('You>> ')
  if data2 == "bye":
     print "You have disconnected!"

I would not use threaded sockets in panda3d. Panda3d provides its own internal networking stack that is much better and has nice hooking in pstats for monetoring. All around better deal.