What are the exceptions which generates while using functions of socket lib in Python language. I have list of exception errors, but dont know which error are for socket function. https://docs.python.org/2/library/errno.html I want to handle every error cases in TCP socket.
import socket
import sys
sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = ('192.168.1.26', 56000)
while True:
try:
sock.connect(server_address)
break
except socket.error as e:
print "error while connecting ::%s",e
while True:
try:
# Send data
message = 'This is the message. It will be repeated.'
print >>sys.stderr, 'sending "%s"' % message
sock.sendall(message)
except socket.error as e:
print "error while sending ::%s",e