Lesson 4 of 15
Ports & Protocols
Ports & Protocols
A port is a 16-bit number (0–65535) that identifies a specific process or service on a host. Combined with an IP address, a port forms a socket address — the endpoint for network communication.
Port Ranges
| Range | Name | Description |
|---|---|---|
| 0–1023 | Well-known | Assigned to common services (HTTP, SSH, DNS) |
| 1024–49151 | Registered | Used by applications (MySQL, PostgreSQL) |
| 49152–65535 | Dynamic/Ephemeral | Temporary client-side ports |
Common Ports
| Port | Protocol | Service |
|---|---|---|
| 22 | TCP | SSH |
| 53 | UDP/TCP | DNS |
| 80 | TCP | HTTP |
| 443 | TCP | HTTPS |
| 3306 | TCP | MySQL |
| 5432 | TCP | PostgreSQL |
| 6379 | TCP | Redis |
| 8080 | TCP | HTTP Alternate |
Your Task
Implement two functions:
portInfo(port)— returns an object withrange("well-known","registered", or"dynamic") andservice(known service name or"unknown")parseSocketAddress(addr)— parses a string like"192.168.1.1:8080"into{ ip, port, service, range }
Node.js loading...
Loading...
Click "Run" to execute your code.