Network Security & Sockets
Common attacks and defences, plus how applications talk over the network using sockets and WebSockets.
Cheat sheet
- ▸Symmetric (AES) is fast; asymmetric (RSA/ECC) solves key exchange.
- ▸Hashing (SHA-256) is one-way; used for integrity and passwords (with salt, bcrypt).
- ▸Firewall filters traffic by rules; IDS detects, IPS blocks.
- ▸Attacks: DDoS, MITM, phishing, SQL injection, XSS, CSRF.
- ▸Socket = IP + port; server: socket → bind → listen → accept.
- ▸WebSocket: full-duplex persistent connection upgraded from HTTP.
Polling vs Long polling vs WebSocket
| Technique | Connection | Latency | Overhead |
|---|---|---|---|
| Polling | New request each interval | High | High |
| Long polling | Held open until data | Medium | Medium |
| WebSocket | Persistent, bi-directional | Low | Low |
| SSE | Persistent, server → client | Low | Low |
Top 10 campus interview questions
Quick quiz
1. Which is asymmetric?
2. Hashing is:
3. Full-duplex persistent browser connection:
4. Digital signatures are created with:
5. An IPS differs from an IDS because it: