200-901 Network Fundamentals Practice Question
A developer is building a Python script that must resolve a hostname to an IPv4 address and then connect to a specific TCP port. The script uses `socket.getaddrinfo(host, port, family=socket.AF_INET, type=socket.SOCK_STREAM)`. What does the returned list contain?
⚠ Common exam trap
The trap here is assuming that hostname resolution returns just an IP string or a custom object, when `getaddrinfo` actually returns structured tuples designed for direct socket creation.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Tuples of (family, type, proto, canonname, sockaddr) for each address that matches the criteria.
`socket.getaddrinfo` resolves a host and service into a list of 5-tuples containing family, type, protocol, canonical name, and socket address. When filtered with `AF_INET` and `SOCK_STREAM`, the results are IPv4 TCP endpoints ready for socket creation. This design supports multiple addresses and protocol independence, which is why developers use it instead of the simpler but less flexible `gethostbyname`.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
A dictionary mapping address families to lists of IPv4 addresses.
Why it's wrong here
The function returns a list of tuples, not a dictionary. A dictionary keyed by address family would not preserve the order of results and would not include the socket type, protocol, or canonical name. The tuple format is specifically designed to be passed directly to `socket.socket()` and `socket.connect()` without transformation, which a dictionary would not facilitate as cleanly.
- ✗
A single string containing the IPv4 address in dotted-decimal notation.
Why it's wrong here
`getaddrinfo` does not return a bare string. It returns a list of tuples because a hostname may resolve to multiple addresses, and the caller needs family, type, and protocol information to create a socket correctly. Returning only a string would lose the port and socket parameters and would not support iteration over multiple results. Therefore, this option misrepresents the function's output format.
- ✓
Tuples of (family, type, proto, canonname, sockaddr) for each address that matches the criteria.
Why this is correct
`socket.getaddrinfo` returns a list of 5-tuples: address family, socket type, protocol, canonical name, and a socket address tuple. With `family=socket.AF_INET` and `type=socket.SOCK_STREAM`, it filters for IPv4 TCP endpoints. Each sockaddr is a (host, port) pair for IPv4. This structure lets a client iterate over candidates and attempt connections without manually parsing DNS responses or constructing sockaddr structures.
- ✗
A list of `ipaddress.IPv4Address` objects representing resolved addresses.
Why it's wrong here
`getaddrinfo` returns raw tuples with string or numeric sockaddr components, not `ipaddress.IPv4Address` objects. The `ipaddress` module is separate and would require manual conversion. Using `getaddrinfo` is preferred when writing protocol-agnostic code because it handles both IPv4 and IPv6 and returns the exact arguments needed for socket creation. This option incorrectly assumes an object-oriented representation that the function does not provide.
Visual reference
Go deeper
Related to this question
About these practice questions
This 200-901 question is part of Courseiva's 975-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Cisco exam blueprint
This 200-901 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 200-901 exam.