INFRASTRUCTURE LEARNINGINFRASTRUCTURE LEARNING
インフラ大全インフラ大全IT INFRASTRUCTURE / LEARNING
Infrastructure learning guide
Find a lesson or lab/

Esc to close · Search terms stay on your device

LEARNING日本語

Topic lessonTopic: networking foundations

TCP vs UDP: ports, listeners and message boundaries

TCP provides an ordered byte stream; UDP carries datagrams. Both use port numbers, but the same number does not make them interchangeable. Use a fictional document service to distinguish an intended endpoint, TCP listening and establishment, and an application response.

What you will learn

Read an IP/transport/port endpoint, explain stream versus datagram boundaries, and limit a connection claim to the evidence supplied.

Prerequisite

An IP address identifies a network-layer endpoint; a transport port helps distinguish a TCP or UDP endpoint. All examples are fictional and use documentation addresses and names. No connection, OS command, AWS account or log submission is required.

Read the address, transport and port together

Call the document service docs.example. Looking up destination information through DNS differs from finding a working application there. Our illustrative client is 192.0.2.10:50324, with intended target 192.0.2.20:443/TCP. The source port 50324 is chosen for this example, not an OS-wide default.

Read three fields in the example target
FieldValueMeaning
Destination IPv4192.0.2.20The address selected; reachability remains unknown.
TransportTCPThe transport intended for this example, distinct from UDP.
Destination port443The TCP destination port; no certification of a running or safe application.

TCP/443 and UDP/443 are different transport endpoints. A registered service name cannot establish the actual application, expected response or safety. Keep address, transport and port together.

The line identifies an intended target, not an observed successful connection
The line identifies an intended target, not an observed successful connection1: Client 192.0.2.10 :50324 — Specified endpoint; sending, reachability and establishment unverified — Target 192.0.2.20 TCP/4431Client 192.0.2.10:50324Target 192.0.2.20TCP/443The line identifies an intended target, not an observed successful connection1: Client 192.0.2.10 :50324 — Specified endpoint; sending, reachability and establishment unverified — Target 192.0.2.20 TCP/4431Client192.0.2.10:50324Target192.0.2.20TCP/443
  1. Client 192.0.2.10 :50324 → Target 192.0.2.20 TCP/443Specified endpoint; sending, reachability and establishment unverified
Client 192.0.2.10 :50324
192.0.2.10:50324
Target 192.0.2.20 TCP/443
192.0.2.20:443/TCP

Compare a TCP stream with UDP datagrams

TCP (Transmission Control Protocol) offers applications an ordered byte stream, with mechanisms including retransmission. One write need not correspond to one read. The application protocol must define message length or termination.

Suppose an application writes AB, then CD. When the same four bytes are received in order, possible reads include ABCD, or A followed by BCD. These are alternative groupings, not measured packets or timing.

Alternative TCP reads: ABCD or A / BCD, not two simultaneous copies
Alternative TCP reads: ABCD or A / BCD, not two simultaneous copies1: Write AB then CD — Write boundaries are not preserved — Bytes ABCD. 2: Bytes ABCD — Alternative 1; not a measurement — Alternative 1: ABCD. 3: Bytes ABCD — Alternative 2; not simultaneous duplication — Alternative 2: A / BCD123Write AB then CDBytes ABCDAlternative 1: ABCDAlternative 2: A /BCDAlternative TCP reads: ABCD or A / BCD, not two simultaneous copies1: Write AB then CD — Write boundaries are not preserved — Bytes ABCD. 2: Bytes ABCD — Alternative 1; not a measurement — Alternative 1: ABCD. 3: Bytes ABCD — Alternative 2; not simultaneous duplication — Alternative 2: A / BCD123Write AB thenCDBytes ABCDAlternative 1:ABCDAlternative 2:A / BCD
  1. Write AB then CD → Bytes ABCDWrite boundaries are not preserved
  2. Bytes ABCD → Alternative 1: ABCDAlternative 1; not a measurement
  3. Bytes ABCD → Alternative 2: A / BCDAlternative 2; not simultaneous duplication
Write AB then CD
AB, then CD
Bytes ABCD
A B C D (the same four bytes)
Alternative 1: ABCD
Read ABCD together
Alternative 2: A / BCD
Read A, then BCD

UDP (User Datagram Protocol) handles individual datagrams. Sending AB and CD as separate datagrams does not make UDP guarantee delivery, ordering or duplicate protection. OS receive APIs and insufficient-buffer behavior are outside this lesson.

Data models and work left to higher layers
AspectTCPUDP
Data unitOrdered bytes without preserving write boundaries.Datagrams, without TCP establishment.
Higher-layer concernsMessage framing, protection and application meaning.Any required delivery mechanisms, protection and application meaning.
Not establishedA guarantee that every attempt succeeds.A conclusion that every application is unreliable.

Listening differs from establishment and application response

A TCP listener waits for an incoming connection request, potentially at a particular local address. Having a listener differs from having a usable route and applicable traffic permissions from a given peer. This lesson gives no OS or cloud configuration procedure.

The fictional observations below concern one attempt between a named client and its direct TCP peer. A peer is the other endpoint of that connection. If a proxy or load balancer terminates the connection, that observation does not establish a further connection to the application behind it.

What different fictional notes establish
Given noteSupported conclusionStill unknown
IP and TCP/443 appear in configurationAn intended target is specified.Sending, reachability, listener and establishment.
Establishment with the named direct peer was observed in this attemptEvidence about that peer and TCP attempt at that time.TLS validation, HTTP response and document access.
An HTTP refusal was observed for this requestAn HTTP response for that request.The exact refusal reason and other requests or users.

Distinguish UDP from protocols built on it

HTTP/3 uses QUIC, which runs over UDP. Therefore, not all HTTPS traffic uses TCP/443. UDP’s own limited guarantees do not mean a higher protocol adds no mechanisms.

The transport name alone does not determine performance or application success. Those require relevant measurements and identification of the protocol actually used. These figures contain no measured speed, reachability or safety status.

Choose an explanation supported by each case

Choose an option to see the result and explanation.

Only the configured target 192.0.2.20:443/TCP is given. What is established?
Read the answer and reason

Answer: The intended IP, transport and destination port · The target is specified; sending or establishment has not been observed.

Which statement describes UDP itself?
Read the answer and reason

Answer: UDP itself guarantees neither delivery nor duplicate protection · This limits the claim to UDP rather than excluding higher-layer features.

TCP establishment with the named direct peer was observed in this attempt. What remains?
Read the answer and reason

Answer: TLS/HTTP results and application response or access · TCP establishment and higher-layer outcomes are separate conditions.

Two TCP writes contain AB and then CD; the same four bytes arrive in order. Which reading is possible?
Read the answer and reason

Answer: One read may return ABCD · The same byte sequence can have different read groupings; the application must frame its messages.

Check, then explain in your own words

  1. Read the target address, transport and port.
  2. Use AB/CD to explain write and read boundaries.
  3. Separate evidence for one attempt from unverified application outcomes.
Check your understanding: What must be separated before saying “it connected”?

Separate the intended endpoint, observed TCP establishment for one attempt, and TLS/HTTP/application outcomes.

Neither a familiar port nor a configured target proves application success. Explain stream/datagram behavior and restrict observations to the peer and conditions actually supplied.

Sources and conditions checked

Primary references are collected here with their scope, conditions and corresponding sections. Independent expert review and live-environment validation have not been performed.