I was the one asking for this video, you have no idea how much I appreciate you right now. Your videos are some of the best out there when it comes to Java. I am sending your videos to everyone in my college.
Maybe you already have one but perhaps you could do a video on IO? I found it hard to figure out what's a buffered reader, why we insert another file reader inside, what's an output stream etc etc. Also, let's say I wanna learn a new api and it's structure. How would you do it ?
I did a high level video on file IO here a little while back: ruclips.net/video/Ldx3NdGk86o/видео.html I don't go into a lot of detail on that video, but hopefully that touches on some of your questions. Learning a new API can be fun or frustrating depending on the documentation and examples available. I usually try to approach the API with a high level picture in mind of what its intended to do, and then I find the simplest example that accomplishes that. After I start learning the API's jargon, I'll play around with it some more and make sure I understand it, sometimes peaking at the source code if its available. In my experience following an example without context isn't super helpful, nor is diving head first into the documentation without looking at the bigger picture from time to time.
This was an amazing walk through. Network programming in general is super interesting. I would really appreciate it if you cover the NIO way of socket programming.
Hello. thank you for this video. You declared "final int PORT_NUMBER = 12345;" in the "Main" class and used it in the "start()" method of "MyClient" class. However, "MyServer" class returns 50071 or 50072 when it calls "client.getPort()". Could you please explain why the client port number returned is 50071 and not 12345 ?
Happy to do so! PORT_NUMBER is referring to the source port number for the server specifically. The reason both the client and server need this is because the server uses it to bind the server socket and the client uses it as a destination port when it talks to the server. The port that is printed out in the output window is the client's source port (aka the server destination port), which by default is determined by the OS when the client creates the TCP socket.
Yes, Tomcat is adding support for these! I haven't personally tried it, but the docs seem to indicate that virtual thread executors are avilable in Tomcat 11 at least, and there might be some support in Tomcat 10.
Hello, I'm watching your video in Korea :) But if you don't use NIO-socket for reading or writing, then isn't it essentially the same as using multi-platform threads? I'm a bit confused. Thank you for your nice video!
Thanks for the question! If the server has to spin off a thread per request (or thread per client), then you have two main options: 1. Platform threads (the original way) 2. Virtual threads In Java 21 and later, most of the time you'll want do option 2 due to how virtual threads are implemented. Most of the time you'll get a perceived performance boost because the JVM is more efficiently utilizing CPU resources across threads.
Personal preference I suppose 🙂 I know folks who use it every chance they get and others that wish it was never added to the language. What are your thoughts on it? I agree with a lot of what is stated here: openjdk.org/projects/amber/guides/lvti-style-guide
Fantastic explanation of how networks in Java work, Will! Awesome socket programming tutorial 🤗
Thank you!
I was the one asking for this video, you have no idea how much I appreciate you right now.
Your videos are some of the best out there when it comes to Java. I am sending your videos to everyone in my college.
Glad you liked the video! Hopefully this is what you were looking for. Let me know if you have any other requests :)
Maybe you already have one but perhaps you could do a video on IO?
I found it hard to figure out what's a buffered reader, why we insert another file reader inside, what's an output stream etc etc.
Also, let's say I wanna learn a new api and it's structure. How would you do it ?
I did a high level video on file IO here a little while back: ruclips.net/video/Ldx3NdGk86o/видео.html
I don't go into a lot of detail on that video, but hopefully that touches on some of your questions.
Learning a new API can be fun or frustrating depending on the documentation and examples available. I usually try to approach the API with a high level picture in mind of what its intended to do, and then I find the simplest example that accomplishes that. After I start learning the API's jargon, I'll play around with it some more and make sure I understand it, sometimes peaking at the source code if its available. In my experience following an example without context isn't super helpful, nor is diving head first into the documentation without looking at the bigger picture from time to time.
This was an amazing walk through. Network programming in general is super interesting.
I would really appreciate it if you cover the NIO way of socket programming.
I think network programming is cool too. I’ll be sure to make a follow up video talking about NIO sockets as well. Thanks for the comment!
Here you go! ruclips.net/video/h76n2R4HRts/видео.html
@@willtollefson Thank you so much🙌
Great content! Your videos deserve a lot more views. Please keep making Java videos.
Thanks so much. I’ll keep posting Java content when I can!
Appreciate you sharing this, Nice content. Next video on Websocket?
Good idea on WebSocket. Are you looking for a video on the protocol, or the javax.websocket package and associated examples?
@@willtollefson I am looking for example such as chat app or any other eg (serverbrowser). it would be great if you explain how this technology works.
@@rahhi9792awesome - I’ll plan on making a video on that soon!
Coders who know networking are cool. 😎
Haha definitely!
Hello. thank you for this video. You declared "final int PORT_NUMBER = 12345;" in the "Main" class and used it in the "start()" method of "MyClient" class. However, "MyServer" class returns 50071 or 50072 when it calls "client.getPort()". Could you please explain why the client port number returned is 50071 and not 12345 ?
Happy to do so! PORT_NUMBER is referring to the source port number for the server specifically. The reason both the client and server need this is because the server uses it to bind the server socket and the client uses it as a destination port when it talks to the server. The port that is printed out in the output window is the client's source port (aka the server destination port), which by default is determined by the OS when the client creates the TCP socket.
Are virtual threads being updated in the tomcat server?? If so, what is the version??
Yes, Tomcat is adding support for these! I haven't personally tried it, but the docs seem to indicate that virtual thread executors are avilable in Tomcat 11 at least, and there might be some support in Tomcat 10.
@@willtollefson Thanks for the update.
Hello, I'm watching your video in Korea :)
But if you don't use NIO-socket for reading or writing, then isn't it essentially the same as using multi-platform threads? I'm a bit confused. Thank you for your nice video!
Thanks for the question! If the server has to spin off a thread per request (or thread per client), then you have two main options:
1. Platform threads (the original way)
2. Virtual threads
In Java 21 and later, most of the time you'll want do option 2 due to how virtual threads are implemented. Most of the time you'll get a perceived performance boost because the JVM is more efficiently utilizing CPU resources across threads.
Please don't use `var`. It irritates the mind.
Personal preference I suppose 🙂 I know folks who use it every chance they get and others that wish it was never added to the language. What are your thoughts on it? I agree with a lot of what is stated here: openjdk.org/projects/amber/guides/lvti-style-guide