Networking Intro

  • cat /etc/services


  • TCP is reliable, resends the message if it fails
  • UDP is unreliable

Ports and Permissions

  • Systems can only listen to ports below 1024 as root (i.e. they require sudo)


  • Often time servers are described as systems that listen to incoming connections
  • Any computer can be a server


  • netcat nc allows you to setup tcp and udp connections and servers
  • with netcat you can speak tcp directly
  • the communication is bi-directional (the messages flow both ways)
# sudo apt install netcat
nc -l 5000 # listen on port 5000
nc -lp 5000 # listen on port 5000

from another session, you can now send messages to port 5000

nc localhost 5000

You can now type messages in each session and see them from the other session


  • plain-text protocol
  • all that you need is a program that speaks tcp

http verbs

HTTP requests begin with a VERB. Some things each VERB is used for:

  • GET - fetch a document
  • POST - submit a form
  • HEAD - fetch metadata about a document
  • PUT upload a file

There are more (DELETE, OPTIONS etc.)

http headers

Headers have a key followed by a colon : followed by a value. (Like JS objects, minus the comma at the end)

key: value
$ nc 80
GET / HTTP/1.0

Make sure to hit return twice after Host:

You’ll get an http response back (header and HTML payload)