Here you will find out how Web servers process incoming requests from the browser.
It will be a plus if you have basic understanding of the HTTP protocol.
In this video we are creating a ServerSocket that is listening on a specific port.
When a new connection is received, we pass it to a new thread which then reads the content of the stream and parses it into our beloved HTTP format.
Initially the server is written in a way that is as straightforward as possible until we reach an issue while sending large HTTP requests.
The tricky part is the async nature of TCP sockets. InputStream.available() DOES NOT WORK on TCP Socket streams, so we come up with a more cleaver way to read the request.
Link to MDN about HTTP Structure:
https://developer.mozilla.org/en-US/d...
Link to Github Repo:
https://github.com/Cyecize/HTTP-TCP-S...
Timecodes:
0:00 - Intro
2:07 - What is HTTP
4:51 - Project Skeleton
5:56 - Create Server On Port 8080
9:46 - Spawn a Thread for each connection
11:38 - Incorrectly read TCP Stream
16:49 - Parse HTTP Request
23:17 - Serving Files
33:10 - Uploading Files
39:00 - The Issue with TCP Streams
43:06 - Properly read TCP Stream
52:48 - Test
54:51 - Outro
56:03 - Custom Web Server
On this page of the site you can watch the video online Read HTTP Request From TCP Socket Stream In Java (TCP Socket Programming) with a duration of hours minute second in good quality, which was uploaded by the user Cyecize 12 July 2022, share the link with friends and acquaintances, this video has already been watched 1,967 times on youtube and it was liked by 49 viewers. Enjoy your viewing!