As far as I know, when you call socket.settimeout(value)
and you set a float value greater than 0.0, that socket will raise a scocket.timeout when a call to, fo
See my server script, you will get the idea to use it properly.
import socket
import sys
fragments = []
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("192.168.1.4",9001))
s.listen(5)
while True:
c,a = s.accept()
c.settimeout(10.0)
print "Someone came in Server from %s and port %s" %(a[0],a[1])
c.send("Welcome to system")
while True:
chunk = c.recv(2048)
if not chunk.strip():
break
else:
fragments.append(chunk)
continue
combiner = "".join(fragments)
print combiner
shutdown = str(raw_input("Wanna Quit(Y/y) or (N/n): "))
if shutdown == 'Y' or shutdown == 'y':
c.close()
sys.exit()
else:
continue
This script is just to give you an idea about the socket.settimeout().