A look at the code first:
server side (python):
#import the library for connection import socket #going to make a server locally HOST = "localhost" #port PORT = 1337 #put these 2 pieces of data in a tuple ADDR = (HOST,PORT) #buffer size BUFSIZE = 4096 #create a socket object representing the server serv = socket.socket(AF_INET,SOCK_STREAM) #associate with the right address serv.bind((ADDR)) #listen for 1 connetion serv.listen(1) #accept; this is where the program hangs and awaits a client connection #this is where the client (flash) uses the connect function conn,addr = serv.accept() #the program also hangs here in waiting of data sent from the client data = conn.recv(BUFSIZE) #display the data, should be hello print(data)
client side (haxe/AS3):
//define the host var host:String = "localhost"; //define same port var port:Int = 1337; //create socket object var s:Socket = new Socket(); //continue code after connection is established s.addEventListener(Event.CONNECT,done); //connect to the according serer s.connect(host,port); //function done //write a message to the buffer s.writeUTFBytes("hello"); //send message s.flush();
This is the most simple demonstration of connection between a server and flash. With this you can program the game in python and send user input from flash to python, then send the players updated coordinates from python sever to flash.
However, since I am working in haxe, the best method would be to program the server in haxe also and compile that to a java server or a C++ server.