Skip to Content

A stick figure smiling

Here's a preview from my zine, Bite Size Linux!! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

Image of a comic. To read the full HTML alt text, click "read the transcript".

browse more comics! get the zine!
read the transcript!

networking protocols are complicated

book: TCP/IP Illustrated, Volume 1, by Stevens (600 pages)
person: what if I just want to download a cat picture?

Unix systems have an API called the “socket API” that makes it easier to make network connections

Unix: you don’t need to know how TCP works. I’ll take care of it!

here’s what getting a cat picture with the Socket API looks like:

  1. Create a socket: fd= socket(AF_INET, SOCK-STREAM...)
  2. Connect to an IP/port: connect (fd,
  3. Make a request: write (fd, "GET /cat.png HTTP/I.I...)
  4. Read the response: cat-picture= read (fd...)

Every HTTP library uses sockets under the hood

Python: requests.get("")"

person: oh, cool, I could write an HTTP library too if I wanted*. Neat!
* SO MANY edge cases though! :)

AF_INET? What’s that?

AF-INET means basically “internet socket”: it lets you connect to other computers on the internet using their IP address.

The main alternative is AF-UNIX (“unix domain socket”) for connecting to programs on the same computer.

3 kinds of internet (AF INET) sockets:

  1. SOCK_STREAM = TCP (curl uses this)
  2. SOCK_DGRAM = UDP (dig (DNS) uses this)
  3. SOCK.RAW = just let me send IP packets. I will implement my own protocol. (ping uses this)

Saturday Morning Comics!

Want another comic like this in your email every Saturday? Sign up here!

I'll send you one of my favourite comics from my archives every Saturday.
© Julia Evans 2024 | All rights reserved (see the FAQ for notes about licensing)