Re: socket.rcv timeout while-loop

2011-02-07 Thread Dwayne Blind
Dear Stephen, Thanks for telling me this all looked very peculiar. As you said, it did not really need solving. Cheers, Dwayne 2011/2/4 Stephen Hansen > On 2/4/11 9:16 AM, Dwayne Blind wrote: > > @ Stephen Hansen > > Now I am pretty much worried. :'( > > Why? This is all sounding like a probl

Re: socket.rcv timeout while-loop

2011-02-04 Thread Stephen Hansen
On 2/4/11 9:16 AM, Dwayne Blind wrote: > @ Stephen Hansen > Now I am pretty much worried. :'( Why? This is all sounding like a problem that isn't actually a problem. I think you may have over-analyzed yourself into a corner and think you have something to solve which doesn't really need solving.

Re: socket.rcv timeout while-loop

2011-02-04 Thread Dwayne Blind
Thank you very much Jean-Michel Pichavant and Stephen Hansen. @ Jean-Michel Pichavant I will have a look at Pyro. @ Stephen Hansen Now I am pretty much worried. :'( 2011/2/4 Stephen Hansen > On 2/4/11 6:55 AM, Dwayne Blind wrote: > > @ Jean-Michel Pichavant > > I am writing a small multipla

Re: socket.rcv timeout while-loop

2011-02-04 Thread Stephen Hansen
On 2/4/11 6:55 AM, Dwayne Blind wrote: > @ Jean-Michel Pichavant > I am writing a small multiplayer game. Several clients are connected to > the server. Games last, say, 20 seconds. > You can think of the game as a small chat lasting 20 seconds. All the > data received by the server is sent back to

Re: socket.rcv timeout while-loop

2011-02-04 Thread Jean-Michel Pichavant
Dwayne Blind wrote: Thanks to all of you. @ Jean-Michel Pichavant I am writing a small multiplayer game. Several clients are connected to the server. Games last, say, 20 seconds. You can think of the game as a small chat lasting 20 seconds. All the data received by the server is sent back to

Re: socket.rcv timeout while-loop

2011-02-04 Thread Dwayne Blind
Thanks to all of you. @ Jean-Michel Pichavant I am writing a small multiplayer game. Several clients are connected to the server. Games last, say, 20 seconds. You can think of the game as a small chat lasting 20 seconds. All the data received by the server is sent back to the clients. @ Stephen H

Re: socket.rcv timeout while-loop

2011-02-04 Thread Jean-Michel Pichavant
Stephen Hansen wrote: On 2/3/11 9:56 AM, Dwayne Blind wrote: However I would like to set timeout on the socket rcv method, so that the while loop stops exactly after 3 seconds. Is this possible ? I rarely do low-level socket stuff -- [snip] Good point. Python has a module for almos

Re: socket.rcv timeout while-loop

2011-02-03 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Dwayne Blind wrote: or rather timeout = s.gettimeout() b=time.clock() while time.clock()-b<3 : s.settimeout(3-time.clock()+b) try : data=s.recv(1024) except : break s.settimeout(t

Re: socket.rcv timeout while-loop

2011-02-03 Thread Stephen Hansen
On 2/3/11 3:02 PM, Dwayne Blind wrote: > Thanks Stephen. It's really nice of you. > > I have not understood everything though. (I have never used a context > manager before.) > > Here are some comments : > > timeout = s.gettimeout()# Is that the default timeout ? > s.settimeout(3)

Re: socket.rcv timeout while-loop

2011-02-03 Thread Dwayne Blind
or rather timeout = s.gettimeout() b=time.clock() while time.clock()-b<3 : s.settimeout(3-time.clock()+b) try : data=s.recv(1024) except : break s.settimeout(timeout) Sorry for all these messages Dwayne 2011/2/4 D

Re: socket.rcv timeout while-loop

2011-02-03 Thread Dwayne Blind
The solution would be timeout = s.gettimeout() s.settimeout(3) b=time.clock() while time.clock()-b<3 : try : data=s.recv(1024) except : break s.settimeout(timeout) Am I right ? Dwayne 2011/2/4 Dwayne Blind > Thanks Ste

Re: socket.rcv timeout while-loop

2011-02-03 Thread Dwayne Blind
Thanks Stephen. It's really nice of you. I have not understood everything though. (I have never used a context manager before.) Here are some comments : timeout = s.gettimeout()# Is that the default timeout ? s.settimeout(3) # I guess this is a 3 second timeout s.recv(1024)

Re: socket.rcv timeout while-loop

2011-02-03 Thread Stephen Hansen
On 2/3/11 10:13 AM, Dwayne Blind wrote: > Thanks for your answer. I don't want to reset my socket. I want to apply > the timeout to the rcv method only. Setting the timeout does not "reset [your] socket", I don't think. And I get that you want to only timeout recv... that's why I pointed out its a

Re: socket.rcv timeout while-loop

2011-02-03 Thread Dwayne Blind
Thanks for your answer. I don't want to reset my socket. I want to apply the timeout to the rcv method only. What about select ? http://docs.python.org/library/select.html#select.select How to implement it ? Thanks a lot, Dwayne 2011/2/3 Stephen Hansen > On 2/3/11 9:56 AM, Dwayne Blind wrote

Re: socket.rcv timeout while-loop

2011-02-03 Thread Stephen Hansen
On 2/3/11 9:56 AM, Dwayne Blind wrote: > However I would like to set timeout on the socket rcv method, so that > the while loop stops exactly after 3 seconds. Is this possible ? I rarely do low-level socket stuff -- but I think s.settimeout() is what you're looking for. It applies to the whole soc

socket.rcv timeout while-loop

2011-02-03 Thread Dwayne Blind
Hi everybody, I am using Python 3.0. I have such a code : b=time.clock() while time.clock()-b<3 : data=s.recv(1024) However I would like to set timeout on the socket rcv method, so that the while loop stops exactly after 3 seconds. Is this possible ? Thanks a lot, Dwayne -- http://mail.pyt