@@ -39,7 +39,7 @@ def getaddrinfo(host, port, family=0, socktype=0, proto=0, flags=0):
3939 """Given a hostname and a port name, return a 'socket.getaddrinfo'
4040 compatible list of tuples. Honestly, we ignore anything but host & port"""
4141 if not isinstance (port , int ):
42- raise RuntimeError ("Port must be an integer" )
42+ raise ValueError ("Port must be an integer" )
4343 ipaddr = _the_interface .get_host_by_name (host )
4444 return [(AF_INET , socktype , proto , "" , (ipaddr , port ))]
4545
@@ -56,7 +56,7 @@ def __init__(
5656 self , family = AF_INET , type = SOCK_STREAM , proto = 0 , fileno = None , socknum = None
5757 ):
5858 if family != AF_INET :
59- raise RuntimeError ("Only AF_INET family supported" )
59+ raise ValueError ("Only AF_INET family supported" )
6060 self ._type = type
6161 self ._buffer = b""
6262 self ._socknum = socknum if socknum else _the_interface .get_socket ()
@@ -74,7 +74,7 @@ def connect(self, address, conntype=None):
7474 if not _the_interface .socket_connect (
7575 self ._socknum , host , port , conn_mode = conntype
7676 ):
77- raise RuntimeError ("Failed to connect to host" , host )
77+ raise ConnectionError ("Failed to connect to host" , host )
7878 self ._buffer = b""
7979
8080 def send (self , data ): # pylint: disable=no-self-use
@@ -105,7 +105,7 @@ def readline(self, eol=b"\r\n"):
105105 self ._buffer += _the_interface .socket_read (self ._socknum , avail )
106106 elif self ._timeout > 0 and time .monotonic () - stamp > self ._timeout :
107107 self .close () # Make sure to close socket so that we don't exhaust sockets.
108- raise RuntimeError ("Didn't receive full response, failing out" )
108+ raise OSError ("Didn't receive full response, failing out" )
109109 firstline , self ._buffer = self ._buffer .split (eol , 1 )
110110 gc .collect ()
111111 return firstline
0 commit comments