else:
select_error = select.error
+# Function used to create a socket. Can be overridden if needed in special
+# situations.
+socket_factory = socket.socket
class UnexpectedSource(dns.exception.DNSException):
wire = q.to_wire()
(af, destination, source) = _destination_and_source(af, where, port,
source, source_port)
- s = socket.socket(af, socket.SOCK_DGRAM, 0)
+ s = socket_factory(af, socket.SOCK_DGRAM, 0)
begin_time = None
try:
expiration = _compute_expiration(timeout)
wire = q.to_wire()
(af, destination, source) = _destination_and_source(af, where, port,
source, source_port)
- s = socket.socket(af, socket.SOCK_STREAM, 0)
+ s = socket_factory(af, socket.SOCK_STREAM, 0)
begin_time = None
try:
expiration = _compute_expiration(timeout)
if use_udp:
if rdtype != dns.rdatatype.IXFR:
raise ValueError('cannot do a UDP AXFR')
- s = socket.socket(af, socket.SOCK_DGRAM, 0)
+ s = socket_factory(af, socket.SOCK_DGRAM, 0)
else:
- s = socket.socket(af, socket.SOCK_STREAM, 0)
+ s = socket_factory(af, socket.SOCK_STREAM, 0)
s.setblocking(0)
if source is not None:
s.bind(source)