Asked by GIANSH GUPTA KHUNDKER · BIRLA BRAINIACS
Answer: C. socket.connect_ex()
Answer: C) socket.connect_ex()
Explanation: While connect() raises an exception (like ConnectionRefusedError) if a port is closed, connect_ex() handles this gracefully. It returns an error indicator (like 0 for success or specific error codes like 111 for a closed port) instead of throwing an exception, making it perfect for smooth, efficient looping in port scanners.
Answering after opening this box earns no Practice Points.