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

TechniqueConnectionLatencyOverhead
PollingNew request each intervalHighHigh
Long pollingHeld open until dataMediumMedium
WebSocketPersistent, bi-directionalLowLow
SSEPersistent, server → clientLowLow

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: