Java Socket Programming - Send and Download Files Between Client and Server

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

Комментарии • 191

  • @sorendominikkruck5142
    @sorendominikkruck5142 3 года назад +4

    Thank you very much for your tutorial. I searched for a way sending data from an Android device to a raspberry pi and the way using a java socket was the only one that worked for me. I searched a few days through the internet and other ways in java didn't worked for me. I am so happy that i've found you.

    • @WittCode
      @WittCode  3 года назад +2

      Hey Sören! That's great to hear! Thank you for the kind words!

  • @nixer8605
    @nixer8605 3 года назад +5

    i saw some guy i comments asked you to make this video and you did...you are amazing....

    • @WittCode
      @WittCode  3 года назад +2

      Thanks for the kind words! I also thought it was a very cool thing to make haha

  • @kiyimbafahad6169
    @kiyimbafahad6169 4 месяца назад

    Your content will always stand out!
    The way you concisely and precisely describe each step....❤🎉

    • @WittCode
      @WittCode  3 месяца назад

      Thank you so much 😀

    • @TinNguyenThanh-ko6pi
      @TinNguyenThanh-ko6pi 2 месяца назад

      Hello can you give me this code ?

    • @WittCode
      @WittCode  2 месяца назад

      @@TinNguyenThanh-ko6pi I lost this code long ago on my old laptop...

  • @DassVeryGood
    @DassVeryGood 3 года назад +10

    Man’s saving lives out here. Thank you so much, I thought I was done in for this assignment until I found this video!

  • @DominikEnder
    @DominikEnder 2 года назад +2

    This guy just saved my lazy student ass! Greets from Austria!

  • @KevinGonzalez-sn2mq
    @KevinGonzalez-sn2mq 2 года назад +1

    This Guy is saving Litteral Lives

  • @jatinrathi9631
    @jatinrathi9631 3 года назад +4

    randomly land to your channel and Loving it!! ......easy to understand ........ you don't only write code but expaint that too . Thankyou ......keep uploading .... 😍

    • @WittCode
      @WittCode  3 года назад +1

      Great to hearJatin! Thanks so much for the support! 😁

  • @guymichelngabonziza6493
    @guymichelngabonziza6493 3 года назад +1

    Vraiment c'est du bon boulot. Je parles français, mais j'ai tous compris. Thank you very much sir.

    • @WittCode
      @WittCode  3 года назад

      That's great to hear! Thanks for watching 🤠

  • @aptechka7353
    @aptechka7353 Год назад

    зашёл глянуть,как передавать файлы,а тут в начале показывается про постройку внешнего вида приложения и это очень помогло понять JFrame в создании внешнего вида.Всё очень круто!!)И на твой код приятно смотреть)

  • @mohawberel
    @mohawberel 2 года назад +1

    I love ur hints over the video. u made a great work!

  • @martingogaming1777
    @martingogaming1777 2 года назад +1

    Thanks it helped me a lot, I am not really using java sockets, but instead using netty, but sending logic is the same, so thanks for help!

  • @amc1140
    @amc1140 2 года назад +2

    Any advice on not seeing 40 ads in this video? Jk get that money bro. Great explaination, it was super helpful!

  • @perronegro4077
    @perronegro4077 3 года назад

    You are amazing, thank you from Latin America !!!

  • @cursedtrousers8735
    @cursedtrousers8735 3 года назад +5

    What is with the smiley face at the end lol! Awesome content though man

    • @WittCode
      @WittCode  3 года назад +4

      Hey Cursed Trousers 👖👖! It was because I had a green screen issue lol I though it was honestly kind of creepy but I kept it haha

  • @cellodabest
    @cellodabest 3 года назад +1

    You are the GOAT, great video, definitely subscribing

    • @WittCode
      @WittCode  3 года назад +1

      Thanks so much! Welcome to the WittCode family haha 😃

  • @vedikapainjane3591
    @vedikapainjane3591 3 года назад +2

    Thank You! This helped me a lot, very easy to understand

  • @lanzph1269
    @lanzph1269 3 года назад +1

    Thanks For This wittcode!

    • @WittCode
      @WittCode  3 года назад +2

      Anytime Lanz! Thanks for watching!

  • @Ipoyu
    @Ipoyu Год назад

    you saved my family from extinction

  • @pandakuuu
    @pandakuuu 2 года назад +1

    i could find the code for java server client chat but couldnt find the one for file sharing in your website could you help me out?

  • @moghenryV
    @moghenryV 2 года назад

    bro, that's an amazing program to study from. Thanks a lot!

  • @MikeThr33
    @MikeThr33 Год назад

    Cybersecurity left the chat. Besides that really cool tutorial.

  • @bertievisick9889
    @bertievisick9889 3 года назад

    Wittcode coming in clutch......thanks boss

    • @WittCode
      @WittCode  3 года назад

      Anytime Bertie! Thanks for stampeding the like button! 🦖

  • @betzalel8364
    @betzalel8364 Год назад

    ⁠@WittCode do you have any videos on how to implement a gremlin function in a Java client script, that will allow the probability of damaged packets to be input as an argument when the program is executed?

  • @JohnSmith-ej1qv
    @JohnSmith-ej1qv 3 года назад +1

    Thanks man I needed this for class but a little less complicated lol

    • @WittCode
      @WittCode  3 года назад +1

      Hey John! As long as it works 🤠

  • @mohitpandey148
    @mohitpandey148 3 года назад +1

    Sir hats off to you.... plz make more java videos and improve my knowledge as a developer

    • @WittCode
      @WittCode  3 года назад

      Thanks Mohit! I will definitely be making more Java videos! 😃

  • @shia6816
    @shia6816 3 года назад +1

    you are my saver ! Thanks man ! Waiting for your new video about Java

    • @WittCode
      @WittCode  3 года назад

      Hey Shia! Anytime! I'm trying to get a new video out next week on Java 😀

    • @shia6816
      @shia6816 3 года назад

      @@WittCode cool ! I learned a lot about java (especial socket) from your video . Cant waiting to watch it

  • @respawnlel
    @respawnlel 3 года назад

    Thanks for the content man.. Expecting more.

    • @WittCode
      @WittCode  3 года назад

      Thanks Khandaker! There are certainly more of these videos to come! 😀

  • @dillondonovan9074
    @dillondonovan9074 3 года назад +1

    Great video!

    • @WittCode
      @WittCode  3 года назад

      Great to hear Dillon! Thanks for watching! 🤠

  • @khadijamostudio
    @khadijamostudio Год назад

    Thank you for the awesome tutorial! I followed everything you did and double checked using your GitHub code. However, whenever I click on "Yes" for downloading, the file doesn't download on my server :/ can you please help?

  • @akeidz
    @akeidz 3 года назад

    Very helpful! Subscribed and liked :)

    • @WittCode
      @WittCode  3 года назад +1

      Great to hear Ahmad! Glad it helped! 😃

    • @akeidz
      @akeidz 3 года назад

      @@WittCode Just one question at, 40:00 what if I want to send other files extension like pdf, pptx. Does it work the same as the one you code for txt?

    • @WittCode
      @WittCode  3 года назад +1

      @@akeidz Hey Ahmad good to hear from you again! So this program should be able to send any type of file over including pdf and pptx but it can only preview the content of text and images. So you can send over a pdf but not display the content of it. Though I dont think that would be too hard to implement!

    • @akeidz
      @akeidz 3 года назад

      @@WittCode Ah I see, I might have missed that part lol Thanks a lot mister WittCode!

  • @fluffyboy
    @fluffyboy 2 года назад

    Good video dude, really interesting, I made it and works perfectly as it shoud thanks a lot.❤

    • @alperendagistan2846
      @alperendagistan2846 2 года назад

      Can you share your codei please? Because I wrote Server and Client code and when i try to send a file from client to server. I couldn't see my file on the server receiver list. Thanks.

  • @3dportableinc64
    @3dportableinc64 2 года назад

    thank you, very helpful.

  • @arturomtz921
    @arturomtz921 3 года назад

    Thanks man, it really helped me a lot.

    • @WittCode
      @WittCode  3 года назад

      Anytime! Thank you for watching! 😀

  • @rxkshan
    @rxkshan 3 года назад +1

    cool bro plz make videos on android game dev and webdev

  • @arulkumara2077
    @arulkumara2077 3 года назад

    Very useful Thank you so much

    • @WittCode
      @WittCode  3 года назад +1

      Anytime Arul! Thanks for watching! 😃

  • @junioradi6554
    @junioradi6554 2 года назад

    Nice !

  • @parthshah4664
    @parthshah4664 3 года назад +1

    Hey I have school project due in few hours relared to java socket and was wondering if you have any suggestions on how to send and receive objects through arbitrary data

    • @WittCode
      @WittCode  3 года назад +2

      Hey Parth sorry for the late response! I haven't looked into sending objects yet but that could be a new video! I would do what I did in this video and convert each of the objects properties to byte arrays and send them to the server and recreate the object there! There might be another way but I haven't looked into it too much yet! Hope this helps 🤠

    • @parthshah4664
      @parthshah4664 3 года назад +1

      @@WittCode thank you

  • @leylitarab3
    @leylitarab3 3 года назад

    Thank you so much bro 👏👏

    • @WittCode
      @WittCode  3 года назад +1

      Anytime man! Thanks so much for watching! 😀

  • @fitree4482
    @fitree4482 Год назад

    Hi WittCode thank you so much for your easy to understand explanation! But I'm having an issue where I try to send file to the server but nothing happen. Do you know why this is happening?

  • @prometheusli101
    @prometheusli101 3 года назад

    excellent tutorial

    • @WittCode
      @WittCode  3 года назад

      That's always great to hear! Thanks for watching 🤠

  • @sumukhak1074
    @sumukhak1074 2 месяца назад

    can you please share the link to the code. the link in the description did not work. Much needed. Thank you

    • @WittCode
      @WittCode  Месяц назад

      Sadly I don't have this code anymore as I lost it on my old PC. When you say the link didn't work do you mean my website was down?

    • @sumukhak1074
      @sumukhak1074 Месяц назад

      @@WittCode ohh that's fine. No i meant i didn't find the code which i needed that's it

  • @cricschool3451
    @cricschool3451 18 дней назад

    Thanx so much❤🎉

  • @thesos4643
    @thesos4643 3 года назад

    hey great video thanks a lot, but i have a problem , it works fine on my pc, but when i send from another it dosent complete and the readfully keeps waiting and not recieving, every other function i have works so the other pc is for sure connected to the socket but it dosent read all bytes

    • @thesos4643
      @thesos4643 3 года назад

      The readInt is receiving a different value from the writeInt in the client and idk why :(

  • @nishattabassum819
    @nishattabassum819 2 года назад

    Can I also share pdf file and download it instead of text or png file, using this method?

  • @theodoroskapsalis5232
    @theodoroskapsalis5232 2 года назад

    The code is missing from your website can you please provide the code????

  • @jacobchammai3704
    @jacobchammai3704 3 года назад +1

    excuse me but can this code be used to send data over devices connected on the same local host? or what is the purpose of it otherwise?

    • @WittCode
      @WittCode  3 года назад +1

      Hey Jacob! Yes you can use other devices you just have to provide the right connection details to the socket object! The client uses localhost because the server is on the same computer. If you were using another computer you need to specify the IP address of the server! It won't be localhost! Hope this helps!

    • @jacobchammai3704
      @jacobchammai3704 3 года назад +1

      @@WittCode so if the client was another device, i would have to specify the private IP address of the pc that the server is open on right?

    • @WittCode
      @WittCode  3 года назад +1

      @@jacobchammai3704 that is correct! A socket object is IP address and port number to communicate on! So supply the port number the server is listening on and it's IP address!

  • @arslanmir8833
    @arslanmir8833 6 месяцев назад

    it's an amazing video . THanks a lot you saved my lazy student ass , but I can't find the code in your website.

  • @binjabdu
    @binjabdu 3 года назад

    gold video !

  • @DollyKumari-m1g
    @DollyKumari-m1g Год назад +1

    code is not available in your website

  • @Hassan-mona
    @Hassan-mona 2 года назад

    if i want to send files from server to clients what should i modify

  • @ArunKumar-gp2vq
    @ArunKumar-gp2vq 3 года назад

    What if I wanted to maintain a record of file being shared like at what time and etc?
    How will this be done?
    Thanks

    • @WittCode
      @WittCode  3 года назад

      Hey Arun! I would use the Java date class and after a file is sent just have a method that records the time and then saves it somewhere.

  • @deema3861
    @deema3861 2 года назад

    Thanks for your helpful videos, I wonder if there is a way to contact you, I want to ask some important questions if you don't mind

  • @amindendani6823
    @amindendani6823 Год назад

    When I click on the file in the server Fram
    Nothing happened

  • @nachwakraiem1572
    @nachwakraiem1572 3 года назад

    thank you very much it's great video . but if you can help me i want send and download files between multi clients and server !!
    you are amazing .

    • @WittCode
      @WittCode  3 года назад

      Hey Nachwa! That is definitely a video for the future! 😀It will be the same thing but with multiple threads to handle multiple clients.

  • @kresimirsumiga1584
    @kresimirsumiga1584 Год назад

    How to transfer complex objects, lets say color of a circle?

  • @دازيسان-س3ذ
    @دازيسان-س3ذ Год назад

    Where is the code i don't founded when get to download it

  • @ehabwa1167
    @ehabwa1167 2 года назад

    Thnx for this amazing video
    YOU ARE PERFECT 👌
    But when I run the client project
    The labels don't appear ?
    Please i need your help

  • @charbelchammai845
    @charbelchammai845 3 года назад

    Excuse me i am having a little problem i hope you can help me with it, i want to try and run this server from a button from my application for a uni project, when i tried running it with the Server.main(new String[0]); it freezes and the whole IDE stops working, so i thought i would try and run it using threads, i did it but the application does not seem to run, i would really appreciate any help. thank you in advance

    • @WittCode
      @WittCode  3 года назад

      Hey Charbel! What do you mean by run this server from a button? You mean you press a button on a GUI and the server starts? In this example the server is up and running when the application starts.

    • @DimitrisTsoykalas
      @DimitrisTsoykalas 2 года назад

      you need onother thread....

  • @huzaifa6466
    @huzaifa6466 5 месяцев назад

    Can't find it on ur website 😢

  • @shamsakanwal2182
    @shamsakanwal2182 3 года назад

    Can u plz share these two files:client and server?

  • @alirazasharafat9351
    @alirazasharafat9351 2 года назад

    Thanks for this video. Please can you send us the code of this video?

  • @seifeldienahmed820
    @seifeldienahmed820 Год назад

    you saved my ass dude :)

  • @gersonsoccarobuis3910
    @gersonsoccarobuis3910 2 года назад

    nice!

  • @ashul2551
    @ashul2551 3 года назад

    Its posible to dont choose the file and send a specific file every time u execute it ?

    • @WittCode
      @WittCode  3 года назад +1

      Hey there! Yes you can! Instead of doing the JOptionPane just have create a File object from the file you want to send and send that over!

  • @muh.redhoarifrahman3586
    @muh.redhoarifrahman3586 3 года назад +1

    good bro

    • @WittCode
      @WittCode  3 года назад +1

      Thanks for the kind words! 🤓

  • @rxkshan
    @rxkshan 3 года назад +2

    wittcode please give the sourcecode of this Java Socket Programming - Send and Download Files Between Client and Server

    • @WittCode
      @WittCode  3 года назад +1

      Hey man! Yeah I'm gonna upload it to my GitHub today so I'll post the link in the description!

    • @rxkshan
      @rxkshan 3 года назад +1

      You are cool man

    • @rxkshan
      @rxkshan 3 года назад +1

      @@WittCode plzz do it

    • @WittCode
      @WittCode  3 года назад

      Hey dude sorry I forgot about this! I'll get it to today and send the link to you here 🤓

    • @rxkshan
      @rxkshan 3 года назад

      @@WittCode thanku but fast wittcode!

  • @RobvanBode
    @RobvanBode 8 месяцев назад

    Code no longer available?

  • @kristanbottjer8001
    @kristanbottjer8001 3 года назад

    does this still work if you put the server and cient int the same project but diffrent packages?

    • @WittCode
      @WittCode  3 года назад +1

      Hey Kristan! That's an interesting question! I believe you could by running them with separate threads? So implement the runnable interface to the server class and set it up and run it in the overriden run() method. And then run the client as is. Or vice versa. There might be other ways but I'm not entirely sure. Hope this helps!

    • @kristanbottjer8001
      @kristanbottjer8001 3 года назад

      @@WittCode it does work however with an inconvenience. it does not save the files or pic's.

    • @WittCode
      @WittCode  3 года назад

      @@kristanbottjer8001 it doesn't save the files when you use another thread? It does when you run it normally though right?

  • @l4vos99
    @l4vos99 3 года назад

    What changes do I need to make to send multiple files?

    • @WittCode
      @WittCode  3 года назад +1

      Hey there! You can send as many files as you want! No changes needed 🤠

  • @aiml5910
    @aiml5910 Год назад

    Hey how to transfer folders?

  • @yomiyoubelay1789
    @yomiyoubelay1789 2 года назад

    would you please upload the source code for this program

  • @bhanuduhan9765
    @bhanuduhan9765 3 года назад

    i am facing ana error C:\Users\PC\IdeaProjects\client bhanu\src\client3.java:9:8
    java: class Client is public, should be declared in a file named Client.java

    • @WittCode
      @WittCode  3 года назад

      Hey there! It seems like you created a class called Client in a file where the name is not Client.java? It seems like you might have named it Client3.java. Make sure the name of the class and file match!

    • @bhanuduhan9765
      @bhanuduhan9765 3 года назад

      I have one more issue can we open file directly means when the file recive at server side it get open automatically

  • @arslanmir8833
    @arslanmir8833 6 месяцев назад

    I can't find the code

  • @andyvuitton5559
    @andyvuitton5559 Год назад

    i have done everything correctly except for the server code . someone please help

  • @MonsieurDOjo
    @MonsieurDOjo 3 года назад

    yes can we put a chat within?

    • @WittCode
      @WittCode  3 года назад

      Hey there! You most certainly can! However this wouldnt be an easy addition. I'll be making a video on a messenger like that in the future 🤠

  • @momon1951
    @momon1951 День назад

    where i can download the code?

    • @WittCode
      @WittCode  36 минут назад

      Sorry but I never pushed this to a repo and the computer I coded it on broke :(

  • @kumak9890
    @kumak9890 3 года назад

    Can we create the booking system using this socket programming?

    • @WittCode
      @WittCode  3 года назад +1

      Hey there! Sorry but can you explain the booking system to me or give me more details?

    • @kumak9890
      @kumak9890 3 года назад

      @@WittCode for example, i like to create a reservation system for hotel. So the server will calculate the price arh sent back to the client, and the client can download the receipt.. That's what I think.. Thanks WittCode

    • @WittCode
      @WittCode  3 года назад +1

      @@kumak9890 This could definitely be made this way! Im not sure if it is the best way but you could get the values from the client and parse them and then create a file on the server with the calculated values and send it back to the user just like in this video! Maybe an email would be better for something like this?

    • @kumak9890
      @kumak9890 3 года назад

      @@WittCode exactly..Can you explain the about the Email? Not fully understand 😅

    • @WittCode
      @WittCode  3 года назад +1

      @@kumak9890 No worries! I'll actually be making a video on how to send an email with Java at some point so that'll probably explain it best. But I would say when you get a purchase from the client parse the values and send an email receipt?

  • @DimitrisTsoykalas
    @DimitrisTsoykalas 2 года назад

    Someone is deleting my comments?....or its yt faulty?

  • @mdgeek99
    @mdgeek99 2 года назад

    I couldn't download the code bro😓

  • @tr3892
    @tr3892 Месяц назад

    how can i download this code ?

    • @WittCode
      @WittCode  Месяц назад

      Sorry bro I lost this code a while back...

  • @piyushkesharwani1987
    @piyushkesharwani1987 3 года назад

    Is this necessary to connect devices to same network ?

    • @WittCode
      @WittCode  3 года назад +1

      Hey Piyush! They do not need to be on the same network but you need the right connection information. You just have to pass this into the Socket constructor. 😃

    • @piyushkesharwani1987
      @piyushkesharwani1987 3 года назад

      Ok. But I am getting connection timed out error when trying to send the file to another devices. Can you help me with that ?

    • @WittCode
      @WittCode  3 года назад +1

      @@piyushkesharwani1987 Does the server that you are connecting to have a Public IP address or a private one?

    • @piyushkesharwani1987
      @piyushkesharwani1987 3 года назад

      @@WittCode Its my friend's PC

    • @WittCode
      @WittCode  3 года назад

      @@piyushkesharwani1987 I'm guessing your friends computer is on a private network so the router will have a public address but your friends computer will most likely be private. I am not sure how to work around this but if I do I'll let you know 🤠

  • @ddh6559
    @ddh6559 3 года назад

    can you change from localhost to public

    • @WittCode
      @WittCode  3 года назад +1

      Hey there! You can! With a socket connection you just need to provide the correct port number and IP address that you want to connect to. So you would use the target IP address as opposed to 'localhost' in the socket constructor.

    • @DimitrisTsoykalas
      @DimitrisTsoykalas 2 года назад

      @@WittCode but how we can open the address?..i just made the question one more time in some comment
      but put it also here in case you have time and you want to help...

  • @khaoula2359
    @khaoula2359 2 года назад

    where is the code ???????????

  • @TinNguyenThanh-ko6pi
    @TinNguyenThanh-ko6pi 2 месяца назад

    why can't i see your code ?

    • @WittCode
      @WittCode  2 месяца назад

      What do you mean bro?

    • @TinNguyenThanh-ko6pi
      @TinNguyenThanh-ko6pi 2 месяца назад

      @WittCode i can’t see your source code

    • @WittCode
      @WittCode  2 месяца назад

      @@TinNguyenThanh-ko6pi oh yeah this is an old video. The laptop I wrote the code on died and was lost with it! You'll just have to copy the code in the video

  • @KamrulIslam-ke9jh
    @KamrulIslam-ke9jh 3 года назад

    Is this UDP or TCP ? Please let me know

    • @WittCode
      @WittCode  3 года назад +1

      Hey Kamrul! This project uses Java sockets which implement TCP. So the file contents should be arriving in order and checks should be in place.

    • @KamrulIslam-ke9jh
      @KamrulIslam-ke9jh 3 года назад

      Thanks a lot Brother. Best wishes to you.

    • @KamrulIslam-ke9jh
      @KamrulIslam-ke9jh 3 года назад

      Is there ftp protocol to transfer the file ?

  • @Rockstar04099
    @Rockstar04099 Год назад

    Please send me the code

  • @9911476524
    @9911476524 10 месяцев назад

    Can we send file of a particular ip address instead of local host

  • @IXIIMI
    @IXIIMI Год назад +1

    Hi WittCode thank you so much for your easy to understand explanation! But I'm having an issue where I try to send file to the server but nothing show up in the Server Jframe.
    Here is the link of the code that I have done: docs.google.com/document/d/19OFc0GoOcXTWs7APUwvJAHf1wJJK4tKPp9eZq_vPMrc/edit?usp=sharing.
    BTW, What IDE are you using? Can you give me a download link?

  • @RazanAlFaisal
    @RazanAlFaisal Год назад

    would you please upload the source code for this program