Here I go again.
I have the simplest of ideas...yet cannot seem to find a solution to implement it:
from socket import * import time BUFSIZE = 256 IP = 'localhost' PORT = 25000 ADDR =(IP, PORT) tcpCliSock = socket(AF_INET, SOCK_STREAM) tcpCliSock.connect(ADDR) tcpCliSock.send('I want a response from you server') #Here I would like to have a while and print dots #each second that goes by without an answer #print #while len(resp)==0: # resp = tcpCliSock.recv(BUFSIZE) # print '.' # time.sleep(1) #print resp = tcpCliSock.recv(BUFSIZE) print 'I've received:',recv
I've tried the socket setdefaulttimeout(), but that makes the program exit when timeout is reached for socket read. I've thought of a thread but seems too damn complicated for such a simple idea. Isn't there a way to give the socket read a Timeout value like in C (setsockopt() using a timeval structure)?
I'll welcome any idea:)...