As I’m learning as I go (it feels like once you learn to program, a new world of game design reveals itself in front of you), I’d like to have login and log off possibilities. I’m waiting for Oldjim to make a proper server for CoS, but since is extremely busy, and is unable to respond, I’m placing my request here!
I need a python server that allows me to use a database to register or compare user data. And send simple info to the clients, to show they are connected.
I tried a simple online tutorial, but the server disapears as soon as it blinks :no: it doesn’t run till I press Esc.
the server code goes like this:
# UDP server example import socket server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) server_socket.bind(("", 5000)) print"UDPServer Waiting for client on port 5000" while 1: data, address = server_socket.recvfrom(256) print "( " ,address, " " , address , " ) said : ", data
and the client:
# UDP client example import socket client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) while 1: data = raw_input("Type something(q or Q to exit): ") if (data <> 'q' and data <> 'Q'): client_socket.sendto(data, ("localhost",5000)) else: break client_socket.close()