I think this is the best video on KZbin about I/O streams and sockets.
@bernardkingsley85984 ай бұрын
Is there any way I can see your code
@amc11402 жыл бұрын
Thank you for taking time to explain each step in simple terms. I tried this on my own and was hung up on how each CH object could share 1 updated array list, but then you pointed out the beauty of static variables!
@WittCode2 жыл бұрын
Thanks so much man! Also love your taste in music haha 🎸
@amc11402 жыл бұрын
@@WittCode hell ya Java and Punk Rock are a 90s dynamic duo🤘
@og_yamiatan39572 жыл бұрын
@@WittCode can i make those names of clients in diferent color ?
@Rohan-Prabhala4 күн бұрын
@@og_yamiatan3957 I mean it's in the cmd prompt so prob not, but if you make a GUI for it you could find a way
@uuo49302 жыл бұрын
This truly explains everything so clear, thanks man
@cybernetic777 Жыл бұрын
This is so exciting!!! I had been trying other tutorials, even paid ones and had problems with all the others. On this one everything went perfect.
@GiyuTomiokaTheOneAndOnly Жыл бұрын
This dude literally explained my entire 5 months course in a 40 minute video
@weaponkid11212 жыл бұрын
Haven't even finished the video yet but I'm happy I found this channel!
@xxx4am6 ай бұрын
Thank you WittCode , you have just earned a new subscriber. I cannot begin to explain how helpful and useful your videos are especially this one. I am a software engineering student and I can safely say that this one video is more useful than my entire Java programming class.
@WittCode17 күн бұрын
😀
@cristiangligan-ignatescu7712 күн бұрын
Thank you so much dude! Consider becoming a teacher in the future 🙏 You have that pedagogical talent :)
@MostafaMahmoud-cj2sh Жыл бұрын
IT WORKED, THANKS I'VE BEEN LOOKING FOR THIS FOREVER, BUT NO TUTORIAL COULD EXPLAIN IT AS YOU DID
@imanjallali82582 жыл бұрын
Let me just tell you one thing. Thanks for Being in KZbin to share content most are not capable of doing.
@WittCode2 жыл бұрын
Thanks so much!
@romanzdev6 ай бұрын
Remember to use 'Thread-Safe" collections or manage synchronization in this example.Our static arraylist is a shared resource, and can be accessed by multiple threads simultaneously, where each one can add, remove or read.
@pawe74202 жыл бұрын
Wow man, you really clearly showed how to make such chat in Java, thanks a lot! :)
@UninspiredFilm5Ай бұрын
THIS IS SO COOL! And I managed to reinforce sockets, IO, AND threads ALL AT ONCE
@jadabouzeid91652 жыл бұрын
Thank you so much for this video! Very well explained, it helped me a lot for my university project.
@irinatrandafir73902 жыл бұрын
You explain everything so well and simple ♡
@freddiewittmann14943 жыл бұрын
Great work! I love the thumbnail! So many WittCodes!
@WittCode3 жыл бұрын
Thanks for the support Freddie! 😎
@spenzr6920 Жыл бұрын
So underrated!!! I wish you'll gain more subscribers and viewers. Amazing video
@jackinquisitor9645 Жыл бұрын
Thx for your tutorial, I finally understand how socket work
@wenwengalarpe1434410 ай бұрын
I understand all men you're a great teacher!!
@harrygabbi51812 жыл бұрын
great video thanks for making it i was stuck on this for so long
@maxhitmemedi65982 жыл бұрын
You are a lifesaver man, thank you a lot you are saving me a ton of hours and nerves :)
@mosesfrancis4976 Жыл бұрын
This is what, I looked for in Java. Thank you so.
@oveezion2 жыл бұрын
Lowkey saved my uni lab work xd , keep up the good work !!
@martingogaming17772 жыл бұрын
Thank you, I had trubles with sending message to multiple clients, because of reading system input, thanks again!
@WittCode2 жыл бұрын
Hey there thanks so much! Yeah the reading input part tripped me up for a while too! 😃
@motodankz4838 Жыл бұрын
Wow you are suck a great teacher. You explain every step. Thank you so much!
@tungle36352 жыл бұрын
thank you so much, this content deserves much more credit
@WittCode2 жыл бұрын
Thanks so much! That means a lot! 😃
@kevincianci54432 жыл бұрын
Your content is amazing brother, keep it up! I would love to see this video with a GUI integration as you said in the end of the video.
@WittCode2 жыл бұрын
Thanks so much Kevin! And I will certainly be making a GUI version of this! Probably using JavaFX 😀
@vikaskotwani95732 жыл бұрын
@@WittCode , hey witt please do that asap
@bhpure304 ай бұрын
great video, wonderful explanations throughout too.
@WittCode17 күн бұрын
😀
@g.7222 жыл бұрын
Very helpful! Thank you so much!
@borissmax3 Жыл бұрын
Thank you! Learned a lot from this
@premkarki25 ай бұрын
Thank you for the clear and concise explanation. I just subscribed you. I wish to watch your more videos.
@WittCode17 күн бұрын
😀
@Tygelin86Ай бұрын
Great tutorial!
@uzumakiuchiha7678 Жыл бұрын
Nice one man. Keep it up!
@rnyah_ Жыл бұрын
I'm so grateful to you, this really so helpful man thank you so much
@mc_mzcgt2 жыл бұрын
Thank you so much!!! This is what I was finding!
@arthurbakker7404 ай бұрын
Great content, learned a lot!
@bernardkingsley85984 ай бұрын
Is there anyway I can see your code by chance, that is if it's working
@haris75212 жыл бұрын
This is simply awesome man 👍❤️
@angelinawho55512 жыл бұрын
You are lifesaver man, thank you a lot :)
@adwa1888s4 ай бұрын
thanks a lot bro, keep the good job.✌
@nadiiar752 жыл бұрын
Greetings from Ukraine! You are awesome! Thank you so much for this great tutorial. It helped me a lot.
@akalankaalutwela77122 жыл бұрын
Thank you very much for this!
@charlesjaussaud18222 жыл бұрын
your video is awesome and helped me a lot. thank you.
@vasantpatel92972 жыл бұрын
this is briliant my friends thank you so much
@sahilbhirud13013 жыл бұрын
Love the thumbnail hahah
@WittCode3 жыл бұрын
Sahil! Good to hear from you man! And yeah I thought it was the coolest one Ive made so far lol
@replikvltyoutube37272 жыл бұрын
This helped me a lot, thanks!
@chetan788 Жыл бұрын
video is very helpful. Thank you.
@0brooo2 жыл бұрын
I took a server side approach instead of a client side approach, love the video tho, thank you
@hvasomhelst8 ай бұрын
thank you so much, saved my homework truly!
@ayushsharma46187 ай бұрын
bro can you send code please
@mihaioprea93982 жыл бұрын
Great video! Really helped!
@freddierobinson9587 Жыл бұрын
this was perfect for me thank you
@m4rt_2 жыл бұрын
In the broadcastMessage method, why compare usernames when you can just do: if (clientHandler != this) since clientHandlers is just an array of the clientHandler instances. Also doing it this way allows there to be multiple users with the same username since it does not rely on unique usernames to broadcast correctly, but instead on the instances. (I have not tested it yet, but it should work, if it doesn't then I will update this comment) Edit: I said I would only update if it didn't work, but it worked and I thought I would update it anyways. TL;DR it works, and its probably the better way to do it.
@antrancaobao7110 Жыл бұрын
yah it sounds correct
@kurwa_mach2 жыл бұрын
Thank you very much, man
@sirojiddingroup2 жыл бұрын
Thanks bro it has been very usefull for me
@karolinemalko17232 жыл бұрын
thank you! Subscribed!
@yashwanth7978 Жыл бұрын
Can you share the code, not able to find in the link you kept in description
@johnnys.8282 жыл бұрын
Thank you very much!
@aladin73392 жыл бұрын
thank uuuuu so much, this is so helpful
@AlexKayzProductions2 жыл бұрын
Great tutorial, thanks
@elifkaragoz26062 жыл бұрын
Which design patterns are we using in this program and which pattern I can implement into the code in addition to develop the code?
@Asswipe692 жыл бұрын
Nice tutorial man, rly need something like tihs :D
@WittCode2 жыл бұрын
Thanks so much! Also, love your username lol
@long3850 Жыл бұрын
very helpful video !
@damiaotiktok0236 ай бұрын
Perfeito bom demais essa aula, ficou muito bom mesmo . Sem enrolação e sem complicação foi ótimo esse tutorial, valeu deixo o meu like e minha inscrição, obrigado
@feuerherz0072 жыл бұрын
Hello sir. Is the code still on your website? i can only seem to see some Javascript. Is it on a github page?
@siradjeddinefisli14402 жыл бұрын
the client message is not sent to all clients !!
@heshakarathnasekara71352 жыл бұрын
awesome video i love it thankyouu
@mahamatmahamatabdoulaye8932 жыл бұрын
Many thanks Sir 😘
@3umaryy Жыл бұрын
Why we can't run the server again? After it being in use? Like turn off the server and Re-open it.
@elishaamenuveve43072 жыл бұрын
Great video!
@ambawadisu20502 жыл бұрын
Thank you man, is that possible to chat only with one person from the group please share if you have such kind of code
@patsondamascus885 Жыл бұрын
i tried it it works but my message dont appear to other clients it only appears in my chat only not other chats'
@Jaa1711Ай бұрын
Thank you so much..!
@WittCode17 күн бұрын
😀
@dabexter6 күн бұрын
Hey wittcode, I hope you see this, I loved the tutorial, and you explained everything very well with a hands on approach, but is it possible to run the clients on different computers? If so, how?
@Rohan-Prabhala4 күн бұрын
i gotchu just run a client-like file on a different computer and use the ip address of your server computer instead of "localhost", also make sure they're on the same network
@dabexter4 күн бұрын
@@Rohan-Prabhala tysm, so i run the client script and not the client handler right?
@kutayyaman2 жыл бұрын
thanks for the video
@fabiansvensson95882 жыл бұрын
Great cover of sockets in general. Just wanted to mention that I got an error in the ClientHandler whenever the Client exited. For some reason, the exception was not thrown and the bufferedReader read a "null" value from the input. I added this line and it worked: if(messageFromClient == null) throw new IOException(); By the way, if we wanted to create a network without the use of an intermediary server, so basically client-to-client direct communication. Any tips on how you could go about doing that? Thank you sir!
@ngocminhpham13582 жыл бұрын
I met that problem, too. The things that if I applied your code, the server won't notify that the client who exited is leaving the chat. Is there another way to do that
@fabiansvensson95882 жыл бұрын
@@ngocminhpham1358 You should add the code that you want to execute in the catch: try { messageFromClient = bufferedReader.readLine(); if(messageFromClient == null) throw new IOException(); broadcastMessage(messageFromClient); } catch(IOException e) { closeEverything(socket, bufferedReader, bufferedWriter); break; } Inside closeEverything, there should be a method called "removeClientHandler();" (this is in the video). If this method is executed then the server should be notifying everyone that the client has left the chat. Double check that you added this catch cluase as well as your "closeEverything" method.
@ngocminhpham13582 жыл бұрын
@@fabiansvensson9588 thanks a lot!
@sankarphat2 жыл бұрын
@@fabiansvensson9588 Oh my god i was desperate while seaching the solution and boom i found your comment. You're a god.
@lara5642 жыл бұрын
at which line do you add this "if(messageFromClient == null) throw new IOException();" ?
@15iunie94 Жыл бұрын
Nice video it was a really nice watch and i learned a bunch of new things from it! Can anyone please explain how to run it in CMD tho? (it looked cool)
@danielluo64992 жыл бұрын
great channel
@RNDev6663 жыл бұрын
tysm for this video! its great! one question tho.. at 21:14 couldn't you check if this!=clientHandler?
@WittCode3 жыл бұрын
Hey good to hear from you again! That is correct! And actually probably a better idea as I did not check for duplicate usernames provided by clients! 😄
@RNDev6663 жыл бұрын
@@WittCode yeah i was wondering abt duplicate usernames lol
@vedant55412 жыл бұрын
thank you so much...
@sebastiangard182 жыл бұрын
Is it a TCP or UDP based communication? Really good Video
@user-hr3wf9rn9o Жыл бұрын
Isn't it safer to convert public classes to private classes if they are not used in another class? or there is a reason for it? Thank you for this incredible work, your explanations are amazing !😍
@kutilkol Жыл бұрын
Runnable passed to Thread in listenForMessage() could be implemented by lambda new Thread( () -> {/*code*/}); because Runnable interface has only 1 abstract method, thus making it functional interface.
@morgard211 Жыл бұрын
Shouldn't we rather use AtomicReferenceArray for the clientHandlers to avoid race conditions since more thread access it?
@romanzdev6 ай бұрын
You are correct, use thread-safe collections or manage synchronization
@americancitizen7485 ай бұрын
Very good!
@HAZARD_LIGHTS3 жыл бұрын
I just wanted to say I love your content and how you interact with your fan base but I was also wondering how to run this program from command prompt and how to configure this for use over WAN networks. PS: this tutorial inspired me to make my own chat room project which has been my first real (successful) program.
@WittCode3 жыл бұрын
Hey John thanks so much for the feedback! To run it over the command prompt you just have to go to where you made the java files and compile it like javac .java and then run it like java . And I have gotten a few questions about making these Java networking programs accessible over the internet and to be honest I am not entirely sure how to do it besides port forwarding or giving your server a public address. Im probably gonna take some time to look into this and make a video on it! 😀
@HAZARD_LIGHTS3 жыл бұрын
@@WittCode Thank you so much, I really appreciate you taking the time out of your day to respond to my request!
@m.misbahalizada98372 жыл бұрын
thank you soo much
@vishnusudarsanam53752 жыл бұрын
Real gem!!
@aladin73392 жыл бұрын
hello i have a question, what should i do to make them connect from different pcs and not on localhost. i tried some solutions but it always give me an error
@or-abylaikhan2 жыл бұрын
nice tutuorial man and one silly question "can I connect to that server from another PC?" Or it works only local host?
@supercrusher1235 Жыл бұрын
I searched your blog but the code isn't there.
@AlthonJohnson2 жыл бұрын
Dope, This was really very helpful.
@WittCode2 жыл бұрын
That's great to hear Althon! Thanks for watching! 😀
@noobmaster08102 жыл бұрын
can the client use anathor computer like LAN ???
@bobfarker4001 Жыл бұрын
This is very impressive and it works. I like your approach with clientHandlers. Im a little confused about how multiple clients can connect using the same port. When I did a similar project in C# i got an error saying something like "this port is already in use". Can anyone explain that to me?
@peterlingas78432 жыл бұрын
Thank you so much for this! I'm new to Java and want to make a chess game that can connect to another PC. Would love to see a video with a UI!
@WittCode2 жыл бұрын
Thanks for watching Peter! I am currently working on that video so I should have it up soon! 😀
@peterlingas78432 жыл бұрын
@@WittCode Looking forward to it! Waiting for the bell to ring.
@peterlingas78432 жыл бұрын
@@WittCode Also, how would I go about hosting a server that any computer can connect to? Is there more to it than changing the "localhost" parameter?
@hplat-vku3 ай бұрын
thank bro ,
@WittCode17 күн бұрын
😀
@wenwengalarpe1434410 ай бұрын
Helpful video thanks for making this. Can you do a server PC and a client mobile phone.
@Gandeon12 жыл бұрын
Heyo, thank you so much for the tutorial! I have a little problem though. If I close one of the client windows and start a new one. The chat is filled with the word "null" and I don't know what would cause it. Any idea how to fix it? 😅
@zhonglin59855 ай бұрын
Ran into the same issue. The fix is to do a null check for what bufferedReader.readLine() returns in run() method in ClientHandler.java, cuz readLine() will immediately return null if the the corresponding Client program gets terminated.
@ismailgunduz72 жыл бұрын
Great video, loved it. Thank you for explaining the details. Is it possible to implement this structure of group chat with graphical user interface? Actually I tried but I couldn't figure it out. It simply didn't work
@nordeenhasan60302 жыл бұрын
Thanks alot
@frankheinzelmann75472 жыл бұрын
How can i start it in the console like you did at the beginning of the Video? And is it possible to cumunicate with friends on other pcs in the same Network And how? I really love your video 👍
@WittCode2 жыл бұрын
Hey again! You can start it in the console by navigating to the folder where the .java files are and then compiling them with javac filename.java and then running it by just java filename. And if they are on the same network they just need to run a client script where the socket connection has the ip address of the server!