# Networks and communication

> **What you will learn**
> How computers find each other, what `localhost:27777` means, and why office
> networks and firewalls keep getting in the way.

## Communication is address lookup

The structure matches postal mail. **It arrives because of the address.**

| Internet | Mail |
|---|---|
| IP address | building address |
| **Port** | room number |
| Domain name | building name |
| DNS | the desk that turns a name into an address |

## IP address — the building

```
192.168.0.15      only valid inside your home or office (private)
203.0.113.7       valid across the internet (public)
127.0.0.1         yourself — this machine
```

**The last line matters.** `127.0.0.1` is the agreed address for "this very
computer", and `localhost` is its nickname. So **an address starting with
`localhost` never leaves the machine.**

## Port — the room number

One computer runs many programs at once, so an address alone is not enough. A
**number** separates them. That is the port.

```
localhost : 27777
└───┬───┘   └─┬─┘
which machine  which program
```

| Port | Common use |
|---|---|
| 80 | web (HTTP) — the omitted default |
| 443 | secure web (HTTPS) — the omitted default |
| 3000 · 5432 · 27777 | numbers individual programs chose |

**Web addresses rarely show a port** because 443 (or 80) is the default and gets
omitted. An unfamiliar number like `27777` means "a program that is not the
default" — exactly the `localhost:27777` in
[First run and first connection](/guide/ht-first-run).

> **"Port already in use"** means another program is already in that room —
> either the same program started twice, or something else took the number.

## Domains and DNS

Numeric addresses are hard to remember, so we name them.

```mermaid
graph TD
  A["you type hyperteams.net"] --> B["ask DNS<br/>'what address is that name?'"]
  B --> C["get 203.0.113.7"]
  C --> D["connect to that address"]
```

**The name can be pointed somewhere else while staying the same.** That is why a
service can move servers without changing the address people use. Conversely, a
DNS change **takes time to spread** (minutes to hours) — which is why right
after a change some people reach the new place and some the old one.

## Office networks and firewalls

Corporate networks generally **block traffic coming in from outside.** That is
the firewall, and blocking is the correct behaviour.

| Direction | Usually |
|---|---|
| Inside → out (browsing, calling an API) | open |
| **Outside → in** (reaching your machine) | **blocked** |

So exposing HyperTeams running on your machine **to the outside** needs a
separate route. That is the tunnel in
[Reaching it from anywhere](/guide/ht-remote-access) — not a hole punched in the
firewall, but **an outbound connection opened from inside** and then reused as a
channel.

```
✗ asking security to open the firewall   → they are right to refuse
✓ using a route opened from the inside   → that is what a tunnel does
```

## Why it is sometimes slow

| Term | Meaning | How it feels |
|---|---|---|
| **Bandwidth** | how much moves at once | large file transfer speed |
| **Latency** | how long one round trip takes | sluggish response |

**A slow AI answer is usually the model thinking, not the network.** Which is
why a faster line does not help.

## Common misconceptions

### "Can I send a colleague my localhost address?"

**No.** `localhost` means *their* computer. They will look at their own machine
and fail. Reaching yours needs a [tunnel](/guide/ht-remote-access).

### "Wi-Fi works, so why can't I connect?"

Having internet and having that port open are separate questions. Corporate
networks commonly block specific ports.

---

## Check yourself

**1. In `localhost:27777`, what does each half mean?**

<details>
<summary>Answer</summary>

`localhost` is **this machine itself**; `27777` is the port saying **which
program** on it.
</details>

**2. Why is the port usually invisible in a web address?**

<details>
<summary>Answer</summary>

**443 (HTTPS) and 80 (HTTP) are defaults and get omitted.** A visible unusual
number means a non-default program.
</details>

**3. How do you reach your machine from outside without opening the firewall?**

<details>
<summary>Answer</summary>

**Open a connection outward first and reuse that channel** — a tunnel. Firewalls
normally only block inbound traffic.
</details>

---

Next, what sits at the far end of that address →
[Servers, clients, the cloud](/guide/it-server)
