Depending on the protocol implementation that you are using, you might have to deal only with exceptions specific to that protocol, or you might have to deal with both protocol-specific exceptions and with raw socket errors as well.
The exceptions that are specific to socket operations are:
getaddrinfo()
cannot find a name
or service that you ask about—hence the letters G, A, and I in its name.>>> import socket
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> s.connect(('nonexistent.hostname.foo.bar', 80))
Traceback (most recent call last):
...
gaierror: [Errno -5] No address associated with hostname
send()
or recv()
to complete. It indicates that the timeout was reached before the operation could
complete normally.