I have written a client server program in which the server sends a program to the client, and the client executes the received program. In this case it is a line drawing program in OpenGL. The problem is that on running the server and client the whole program i.e. sending of the program to server and client execution takes place at times, but at times the execution does not take place. The client gets connected and then its stuck. The program doesn't get stopped either.The same works in my friends system,but in mine it works only sometimes(most of the times it wont). What could be the reason? Am I missing something?
My server code:
from OpenGL.GLUT import * from OpenGL.GLU import * from OpenGL.GL import * import sys import threading import os import socket class ClientThread ( threading.Thread ): # Override Thread's __init__ method to accept the parameters needed: def __init__ ( self, channel, details ): self.channel = channel self.details = details threading.Thread.__init__ ( self ) #Codes to be executed when thread is executed: def run ( self ): a1=self.channel.recv(1024) print "client says:"+a1 print 'Received connection:', self.details [ 0 ] finp = open("stringcheck.py","r") #self.channel.send("#start\n") info = finp.readlines() for record in info: self.channel.send(record) #self.channel.send(info) self.channel.send("#p") server = socket.socket ( socket.AF_INET, socket.SOCK_STREAM ) server.bind ( ( '127.0.0.1', 2713) ) #Listens for connections made to socket. #Specifies maximum number of queued connection. server.listen ( 5 ) while True: channel, details = server.accept() #Create an instance of thread class and call its start method. ClientThread ( channel, details ).start()
from OpenGL.GLUT import * from OpenGL.GLU import * from OpenGL.GL import * import os import socket import threading import thread import subprocess class ConnectionThread( threading.Thread ): def run ( self ): client = socket.socket ( socket.AF_INET, socket.SOCK_STREAM ) client.connect( ( '127.0.0.1', 2713) ) client.send("connected") a=client.recv(1024) b=a f=1 while f: a = client.recv(1024) if a=="#p": f=0 break b+=a #print b exec(b) client.close() ConnectionThread().start()
What could the problem be? I searched the net, but looked in the wrong places I think.