Urgent.News

What's breaking now, across thousands of outlets.

Tech

Part 3 — Networking: From `fetch()` to Packets

Most web developers use HTTP every day. We write fetch() , call APIs, send requests, and handle responses. But lets understand what happens underneath those familiar abstractions. When we write: const response = await fetch ( " https://api.example.com/users " ); how does that request reach another computer? What happens before the server receives it? And why can a request be slow even when the…

Most web developers use HTTP daily without fully understanding what happens beneath those familiar abstractions. When we write `const response = await fetch('https://api.example.com/users');`, we don't consider how the request reaches another computer or why it might be slow even when the application code is fast.

A simplified networking model consists of layers: Application (like HTTP), HTTP, TCP, IP, and Ethernet/Wi-Fi. Each layer addresses a distinct problem, but HTTP doesn't handle everything. HTTPS adds TLS encryption on top of TCP. HTTP/3 uses an alternative protocol called QUIC, which operates over UDP instead of TCP. IP addresses identify network destinations, while ports pinpoint the application's transport endpoint. For instance, port 22 is SSH, port 443 is HTTPS, and port 5432 is PostgreSQL.

Some addresses are noteworthy: 127.0.0.1 is the IPv4 loopback address, referring to the local machine. Private IPv4 ranges are 192.168.x.x and 10.x.x.x. The wildcard 0.0.0.0 refers to all local IPv4 interfaces when used as a listening address.

Routers direct packets between networks, and NAT allows multiple devices with private addresses to share a public IPv4 address. TCP ensures reliable communication through a handshake process, sequence numbers, acknowledgements, retransmissions, flow control, and congestion control. However, TCP delivers a continuous stream of bytes without guaranteeing message boundaries.

DNS resolves domain names into IP addresses. A recursive resolver might use cached records or query the DNS hierarchy to find the correct record. The TTL (Time to Live) in DNS records determines how long they can be cached, which helps reduce repeated lookups but may delay DNS changes from being recognized everywhere.

When we call `fetch('https://api.example.com/users')`, several steps occur under the hood: DNS resolution, TCP connection establishment, TLS handshake, HTTP request, network transmission, server processing, HTTP response, and finally, the client receives the response. This sequence can be affected by factors like DNS lookup time, connection setup, TLS handshake duration, network round trips, packet loss, retransmissions, queueing, and downstream service calls.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

How Upload_Tracker.Py Stops Double-Posting When You Re-Run A Batch

I run my whole asset pipeline on a 1 vCPU, 2 GB RAM box with no GPU. A few months ago I had a batch of 40 sticker assets ready for Adobe Stock, Vecteezy, and Dreamstime.

  • UploadTracker.py prevents double-posting in batch uploads.
  • Script maintains ledger of uploaded assets in text file.
  • Ledger updated after successful upload to track unfinished assets.

Dry-Run Your Asset Pipeline: Validate Covers, Zips And CSVs On A 2 GB Server

Last March I lost a full evening to a header row. I had 60 JPGs ready for Adobe Stock, generated the CSV, uploaded the batch, and every single file came back rejected in under a minute.

  • Author experienced evening-long troubleshooting due to CSV header error
  • Validated all files before uploading to avoid issues
  • Condensed process into four Python scripts to catch failures

Validate bounding boxes from a general vision model

A general model can take an image plus a question and return segmentation, bounding boxes, and object detection, work that used to require its own trained vision system.

  • Validate bounding boxes before using results from general vision model
  • Ensure boxes adhere to schema, have correct coordinates, and include labels
  • Reject invalid boxes outside image, with zero width/height, or missing labels

More from Sunday 18 October →