Network and HTTP programming with Java
You write clients and servers with sockets, connect to services with HttpClient, manage keystores with keytool and configure TLS correctly.
Level 301 · 18 lessons · 15 practice labs
Lessons
Sockets
- A TCP client with Socket
- A multi-client server with ServerSocket
- Socket timeouts and cleaning up resources
- UDP with DatagramSocket
- Name resolution with InetAddress
- Short task: a line-based command server
HTTP
- HttpClient: GET, POST and headers
- Asynchronous requests and retries
- JSON mapping with Jackson
- A small service with the built-in HttpServer
- Request size, timeouts and safe headers
- Short task: a client that fetches and summarises data from the lab API
TLS and keystores
- Keystores and truststores with keytool
- A TLS client and certificate verification
- Trusting every certificate: why never
- A TLS server and choosing protocols
- Short task: make the client trust only the internal CA
Capstone
- Capstone: a health and certificate monitor for the lab services
Practice labs
- Reading a greeting line with Socket: Connect to a service on the lab target with Socket, read the first line and close the connection with try-with-resources.
- A line-based command server: Write a server with ServerSocket that handles TIME, ECHO and QUIT commands and serves each client on a pooled thread.
- Socket timeouts and resource clean-up: Add a read timeout, a connection cap and closing on every path to a server whose threads are exhausted by silent clients so the thread count stays flat under the load test.
- Resolving a list of names to addresses: Resolve all addresses of lab domain names with InetAddress and return the unresolvable ones in a separate list.
- Sending a time query over UDP: Write a client that sends a query with DatagramSocket and retries three times on timeout when no reply arrives.
- Measuring loss and reordering over UDP: Write a pair that sends and receives sequence-numbered datagrams, report lost, duplicated and reordered packet counts and pass the simulated network tests.
- Reading status and headers with HttpClient: Send a GET request to the lab API, return the status code and content type header and set connect and request timeouts.
- Mapping a JSON response to objects with Jackson: Map the list the lab API returns to record objects, ignoring unknown fields and giving a clear error for a missing required field.
- A summary from async requests with retries: Fetch the pages of the lab API concurrently with sendAsync, retry transient errors a limited number of times and produce the overall summary.
- A health endpoint with the built-in HttpServer: Write an endpoint with the built-in HttpServer that returns status as JSON and answers 405 for the wrong method.
- Putting a size limit on the request body: Add a size limit to a handler that reads the body without bound, return 413 for an oversized request and close the stream on every path.
- Hardening a small service with headers and time limits: Add a bounded pool, security headers and error responses that leak no internals to a single-threaded small service and show a slow client does not stall the others.
- Importing the internal CA into a truststore: Import the lab's internal CA into a new truststore with keytool and verify by listing its contents.
- Making the client trust only the internal CA: Remove the trust manager that accepts every certificate, build an SSLContext trusting only the internal CA and show the wrongly named lab server is rejected.
- Protocol choice and certificate monitoring on a TLS server: Set up a TLS server accepting only 1.2 and 1.3 and check the certificate expiry of the lab services, raising a warning for those with under thirty days left.
About this course
You write clients and servers with sockets, connect to services with HttpClient, manage keystores with keytool and configure TLS correctly.
What you will learn
- Sockets
- HTTP
- TLS and keystores
- Capstone
Prerequisites
You should be comfortable with the level 101 and 201 topics of the same path.
Lab environment
Lessons run in your own Kali Linux terminal in the browser, connected to a private lab network. Nothing to install.
Frequently asked questions
- Is this course right for my level?
- The course is at level 301; it assumes you know the topics of the lower-level courses.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.