469,610 Members | 1,798 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,610 developers. It's quick & easy.

Socket object and KeyboardInterrupt exception


Ok, here's my situation. I have a small application that listens to
messages on a UDP port.

When I pass None to settimeout(), and I hit Ctrl+C to interrupt the
wait my exception handler catches the KeyboardInterrupt exception.
However, if I pass any value to settimeout() the exception is not

Here's the code snippet

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('', 12345)

data, msgAddr = sock.recvfrom(1024)
except KeyboardInterrupt:
print 'Caught keyboard interrupt, stopping'
except socket.timeout:
print 'Failed to receive message within 100 seconds.'
except Exception:
print 'Caught exception of type Exception'

I'm running python version 2.3.4 on Red Hat Enterprise 3

Thanks in advance for any info

Jul 19 '05 #1
0 1368

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Ivan Nestlerode | last post: by
1 post views Thread by Koen Vossen | last post: by
4 posts views Thread by DreJoh | last post: by
4 posts views Thread by Tony Nelson | last post: by
6 posts views Thread by alessandro | last post: by
3 posts views Thread by Cheryl | last post: by
2 posts views Thread by manasap | last post: by
2 posts views Thread by Michael Goerz | last post: by
7 posts views Thread by Brendon Costa | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.