0% found this document useful (0 votes)
5 views2 pages

Understanding TCP/IP, HTTP, and REST APIs

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Understanding TCP/IP, HTTP, and REST APIs

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Part 01 :

1. TCP/IP — the plumbing under everything


Think of the internet as a postal system:

●​ IP (Internet Protocol) = the addressing system. Like a house address. Every packet needs a source
and destination IP.​

●​ TCP (Transmission Control Protocol) = the reliable courier. It guarantees delivery, order, and
error-checking. If packets get lost, TCP resends them.​

●​ UDP (User Datagram Protocol) = the throw-a-rock-over-the-fence courier. No guarantee, no order,


just “fire and forget”.​

Three things TCP gives you:

1.​ Reliability: Lost packets are retransmitted.​

2.​ Ordering: Packets arrive in sequence.​

3.​ Flow & congestion control: TCP adjusts the speed so neither side gets overwhelmed.

➡ As a backend developer, you rarely work with raw TCP sockets, but everything you build on
HTTP/HTTPS depends on TCP working under the hood.

2. HTTP vs HTTPS
On top of TCP rides HTTP, the “language” browsers and APIs speak.

●​ HTTP (HyperText Transfer Protocol):​

○​ Request → Response model.​

○​ Methods: GET, POST, PUT, DELETE, etc.​

○​ Headers carry metadata (e.g., Content-Type: application/json).​

○​ Body carries actual data (JSON, HTML, etc.).​

●​ HTTPS:​

○​ HTTP wrapped in TLS (Transport Layer Security).​

○​ Provides encryption (confidentiality), integrity (no tampering), and authentication (server


identity).​

○​ Uses digital certificates (.crt, .pem) issued by Certificate Authorities (CAs).​

➡ In modern backend work, always use HTTPS. Browsers and most clients won’t even talk to plain
HTTP if it involves sensitive data.
3. REST principles
REST = Representational State Transfer. It’s an architectural style for APIs, not a protocol.​
It builds on HTTP but applies conventions:

1.​ Resources, not actions​

○​ Bad: /getAllUsers​

○​ Good: /users​

2.​ HTTP methods mean something​

○​ GET /users → fetch all​

○​ POST /users → create new​

○​ PUT /users/42 → replace existing​

○​ PATCH /users/42 → partial update​

○​ DELETE /users/42 → remove​

3.​ Statelessness​

○​ Each request contains all info the server needs (no hidden session state).​

○​ Example: client sends JWT token on each request, server doesn’t “remember” you.​

4.​ HTTP status codes matter​

○​ 200 OK, 201 Created, 204 No Content​

○​ 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found​

○​ 500 Internal Server Error​

5.​ Caching is built-in​

○​ Headers like ETag and Cache-Control help speed things up.​

➡ REST is what lets a frontend (say React) and a backend (your Java API) talk cleanly.

Where this connects back to you

●​ When you write a Spring Boot API, you’ll expose REST endpoints.
●​ Those endpoints run over HTTP/HTTPS, which run on TCP.
●​ Understanding the layers helps debug weird bugs (e.g., TCP resets, TLS handshake errors, proxy
caching oddities).

You might also like