How could I catch socket.error: [Errno 111] Connection refused exception ?
try:
senderSocket.send("Hello")
except ?????:
print "catch !"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
By catching all
socket.errorexceptions, and re-raising it if theerrnoattribute is not equal to 111. Or, better yet, use theerrno.ECONNREFUSEDconstant instead: