S
Stéphane Ninin
Hello,
I have a few questions regarding sockets with timeouts.
Assuming you set a timeout t on a socket s and then call:
1) s.sendall
Is the socket.timeout exception thrown when
not the data was sent in the given time t
or if nothing was sent ?
2) Similar question for s.send:
Is the socket.timeout exception thrown when
nothing was sent or ... ?
What I am actually trying to do is this:
I have a thread which uses a socket to communicate with a socket server,
the socket sends data to the server, but it shouldnot block on the send,
so I want to do something like this:
def sendall(self,data):
while data:
n = self.send(data)
data = data[n:]
try:
self.request.send(data)
except socket.timeout, e:
if self.isTerminated():
return
but I am not sure this would work the way I want.
(self.isTerminated just checks is some event
has been set by another thread)
Thanks for comments/suggestions/answers,
I have a few questions regarding sockets with timeouts.
Assuming you set a timeout t on a socket s and then call:
1) s.sendall
Is the socket.timeout exception thrown when
not the data was sent in the given time t
or if nothing was sent ?
2) Similar question for s.send:
Is the socket.timeout exception thrown when
nothing was sent or ... ?
What I am actually trying to do is this:
I have a thread which uses a socket to communicate with a socket server,
the socket sends data to the server, but it shouldnot block on the send,
so I want to do something like this:
def sendall(self,data):
while data:
n = self.send(data)
data = data[n:]
try:
self.request.send(data)
except socket.timeout, e:
if self.isTerminated():
return
but I am not sure this would work the way I want.
(self.isTerminated just checks is some event
has been set by another thread)
Thanks for comments/suggestions/answers,