Socket Programming in Java One Way

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ม.ค. 2025

ความคิดเห็น • 141

  • @omkattarle8
    @omkattarle8 ปีที่แล้ว +2

    Как замечательно иметь такого прекрасного учителя на TH-cam! Я хотел бы выразить свою искреннюю благодарность за все знания и информацию, которые вы делитесь со мной и другими зрителями. Ваше усердие и преданность в деле обучения заслуживают самой высокой оценки.
    Спасибо вам за ваше время и труд, которые вы вкладываете в создание контента на TH-cam. Я ценю все уроки, которые вы даете, и надеюсь, что ваше вдохновение и знания продолжат помогать другим ученикам в их учебе.
    Еще раз огромное спасибо за ваше прекрасное обучение на TH-cam! 😄

  • @DeoSTerriere
    @DeoSTerriere 2 ปีที่แล้ว +13

    Some helpful tips:
    1. Temporarily disable your firewall to prevent firewall from stopping network traffic on your chosen port (9999)
    2. You can use
    ObjectOutputStream os = new ObjectOutputStream(s.getOutputStream());
    PrintWriter out = new PrintWriter(os);
    out.println(msg);
    os. close();
    in your client.Telusko corrects his mistake in the next video called "Socket programming in Java Two Way".
    But this also works as seen in the video, so actually you don't need the PrintWriter object:
    os.write(msg);
    os.close();
    3. IMPORTANT: Start your SocServer first and SocClient next!
    4. You have two consoles, because you start two programs. The server is printing the incoming message too its console. So when you see no message, you're probably looking in the console of the client.

  • @biruh-edu
    @biruh-edu หลายเดือนก่อน

    You are the best java lecturer on entire website.

  • @faiseen_talks
    @faiseen_talks 7 ปีที่แล้ว +2

    Best instructor ever and ever. I'm a big fan of you sir. thanks a lot.

  • @alixaprodev
    @alixaprodev 4 ปีที่แล้ว +1

    you are doing very great man. I am learning too much from your channel.

  • @g-l8492
    @g-l8492 4 ปีที่แล้ว +4

    If you get a Error looking like this: java.net.ConnectException: Connection Refused -> It could have following solutions: 1. start server before client, 2. turn off your firewall, or, which worked for me: 3. in your Clien class, make the String end the line with appending
    like this: String str = "Navid Reddy
    " (-> br.readLine() expects a full line (at least on my computer?), I don't know why the code shown in the tutorial seems to work for so many people without ending the line)

    • @musfikuroli
      @musfikuroli 3 ปีที่แล้ว +1

      Thanks a lot. Just adding "
      " worked for me.

    • @JohnDoe-ml2zy
      @JohnDoe-ml2zy 2 ปีที่แล้ว +1

      @@musfikuroli Thanks a lot bro you saved me from going on an endless hunt on StackOverflow
      Edit: You too @G-L

    • @ankanpal9163
      @ankanpal9163 10 หลายเดือนก่อน

      didnt worked bro

  • @royrao951
    @royrao951 8 ปีที่แล้ว +67

    I think you missed "os.close(); " in the client program, right?

    • @arveersingh9728
      @arveersingh9728 8 ปีที่แล้ว

      as long as i know it is not necessary to close every reference.

    • @abhijeetrastogi7087
      @abhijeetrastogi7087 8 ปีที่แล้ว +6

      But it was necessary in my case. as without it the client thread was being closed even before it flushed the data.

    • @programmingforbeginners8706
      @programmingforbeginners8706 8 ปีที่แล้ว +2

      tnx man . .i just found my error . after looking . to run my prog so many times

    • @kundan625
      @kundan625 7 ปีที่แล้ว

      Thanks man

    • @moonbrush5
      @moonbrush5 7 ปีที่แล้ว +2

      Saved my time. Thanks!

  • @bashamsk1288
    @bashamsk1288 8 ปีที่แล้ว +3

    man u r excellent i wasted 2days(12hours) on "what is socket " and u explained just in 2 min and u also told how use socket i subscribed and thank u very much ,i wanted to create a client android app can use this coding?

    • @Cowboy1Brian
      @Cowboy1Brian 7 ปีที่แล้ว

      Did you ever get an answer to this question? Im trying to find out how to send coordinates from one device to another, and display those coordinates in a map on that other device.

  • @parwana1000
    @parwana1000 7 ปีที่แล้ว +3

    Hi navin,i am new to java. Can you tell me what is the use of out variable in socClient program? I mean purpose, as it's not being used... Thank you so much for making such video. You have changed the way of learning and studying. Thank you and and I mean it seriously

  • @xGrofx
    @xGrofx 7 ปีที่แล้ว

    Best tutorial on the subject! Thanks mister!

  • @ziddy26
    @ziddy26 7 ปีที่แล้ว +5

    +Telusko Learnings Why was the PrintWriter created? It was never used. Also I tried without PrintWriter. It worked fine for me.
    OutputStreamWriter osw = new OutputStreamWriter (clientSocket.getOutputStream());
    osw.write(message);
    osw.close();
    Is it necessary to create PrintWriter object?
    Thanks

  • @marcusleeeugene
    @marcusleeeugene 7 ปีที่แล้ว +2

    Great tutorial! You helped me understand about TCP connections! :)

  • @Mr47even
    @Mr47even 8 ปีที่แล้ว +4

    Hey buddy ,
    Grate and simple tutorial . BTW , I did not get it why did you create Print Writer , because you never used it .
    Thx in advance.

  • @koushikshomchoudhury9108
    @koushikshomchoudhury9108 7 ปีที่แล้ว

    My first networking program! Thanks :) tutor!

  • @saadmanahmed860
    @saadmanahmed860 4 ปีที่แล้ว

    exquisite illustration as usual.Your keynotes have always rendered me some good coding understanding

  • @meghamalhotra7814
    @meghamalhotra7814 8 ปีที่แล้ว +1

    Sir , Thanks for such a good tutorial.

  • @santhoshmedide5279
    @santhoshmedide5279 8 ปีที่แล้ว

    You know well ,to teach beginners!!

  • @reshamdevirajasthan2124
    @reshamdevirajasthan2124 5 ปีที่แล้ว

    Very good explanation..Thanks

  • @xiaoyingsun4581
    @xiaoyingsun4581 4 ปีที่แล้ว

    Thanks for the generous share. Btw which kind of Projects did you initiate?

  • @KarshSoni
    @KarshSoni 8 ปีที่แล้ว

    Awesome Telusko Learnings

  • @PratikShende91
    @PratikShende91 6 ปีที่แล้ว +1

    we can also use out.println() in place of os.write().

  • @vanrensburg3760
    @vanrensburg3760 4 ปีที่แล้ว

    Nicely explained thank you, can you talk about how a server can generate a unique ID for client that connects and how one client can communicate with another, through the server.

  • @VrlHtzz
    @VrlHtzz 4 ปีที่แล้ว +1

    Why my program get terminated when I run client class ......
    Server runs fine
    Wht should I do

  • @ashishposte8192
    @ashishposte8192 7 ปีที่แล้ว +2

    In the Client program ,you have created Printwriter but you did not use it at all.

  • @eren96lmn
    @eren96lmn 8 ปีที่แล้ว +10

    os.write(str) line should be replaced with out.println(str) to work properly on some systems.

    • @ayushpratik4208
      @ayushpratik4208 6 ปีที่แล้ว

      Same problem was with me........thanx for ur help

    • @ALSAHER79
      @ALSAHER79 5 ปีที่แล้ว +1

      Eren L
      Thanks a lot. I wasted more than 2 hours to fix the issue.

    • @anmjubaer
      @anmjubaer 5 ปีที่แล้ว +1

      Thanks a lot man.

    • @pruthvirajjadhav1996
      @pruthvirajjadhav1996 4 ปีที่แล้ว

      great help !! but what it makes difference ?

    • @ajinkyasanas2256
      @ajinkyasanas2256 3 ปีที่แล้ว

      Thank u so much

  • @vinayakgarments9182
    @vinayakgarments9182 2 ปีที่แล้ว +7

    Watching this video in 2023..

  • @jintujose_28
    @jintujose_28 8 ปีที่แล้ว +2

    Could you please create a video for how to create a directory on the server side using socket programming in java

  • @cassi4790
    @cassi4790 2 ปีที่แล้ว

    that was very helpful!tysm

  • @JohnDoe-ml2zy
    @JohnDoe-ml2zy 2 ปีที่แล้ว

    I have a problem:
    When I run the client side, it says "Connection Reset" error on the server console. How can I resolve this?

  • @singh6569
    @singh6569 9 ปีที่แล้ว

    Thanks for tut. Just few questions. Do you have tut about JSP?
    To learn JSP ,do someone need to learn JAVA first. What is different b/w java nd JSP?
    Thanks

  • @ravindrareddy2822
    @ravindrareddy2822 8 ปีที่แล้ว

    chala baaga chepparu thanq

  • @shubhamsangale890
    @shubhamsangale890 6 ปีที่แล้ว +1

    Sir, even if pass value "true" with the str in printwriter it works!!!
    can you please let me know the reason??

  • @andevinay1494
    @andevinay1494 5 ปีที่แล้ว

    where you have used Print Writer object out in the client class

  • @varundurvasula7536
    @varundurvasula7536 5 ปีที่แล้ว

    Can we achieve this by using scanner? (instead of bufferedreader)

  • @priyamnagar1497
    @priyamnagar1497 8 ปีที่แล้ว

    On my system os.write() is giving a SocketException but when i use out.println() , then it is working . Why did this happen???... Please Reply.

  • @anchitajain6066
    @anchitajain6066 8 ปีที่แล้ว

    I can't main class with different name as project name and this then gives error on making 2 main class files in same project. I am working in net beans. what should I do ? please help ..

  • @sauravmukherjeecom
    @sauravmukherjeecom 9 ปีที่แล้ว

    Nice. Do u have anything about Java XML parsing?

  • @chhaylin3210
    @chhaylin3210 5 ปีที่แล้ว

    Great video

  • @kaustubh21
    @kaustubh21 4 ปีที่แล้ว

    I want to pass 2 values from client
    i've written os.write(val1) and os.write(val2)
    but how can i accept them on the server

  • @akhilmishra624
    @akhilmishra624 6 ปีที่แล้ว

    Exception in thread "main" java.net.UnknownHostException: local host
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at java.net.Socket.(Socket.java:434)
    at java.net.Socket.(Socket.java:211)
    at Client.main(client.java:12)
    ..sir i am getting this error ...what to do?

  • @hristoplamenov1942
    @hristoplamenov1942 6 ปีที่แล้ว

    Hello guys, just one question - why it deletes the information in the client side after i run it ? It shows the Navin Reddy and then black screen :/

  • @ankushroy919
    @ankushroy919 4 ปีที่แล้ว

    do we need same package for client and server?

  • @vidyasagar-qe9ds
    @vidyasagar-qe9ds 5 ปีที่แล้ว

    how to receive the data from the GPS device /Hardware ,GPS will be sending the data to predefined IP address , please guide

  • @orz5516
    @orz5516 6 ปีที่แล้ว

    if i have a real client - written in angularJs, how this is different? thanks

  • @hussain1755
    @hussain1755 8 ปีที่แล้ว +1

    why did u create printwriter "out" ??
    you never used it in the client socket

    • @SM-vo5gj
      @SM-vo5gj 8 ปีที่แล้ว +1

      this is what i was wondering, and possibly is source of problems a couple comments up- with os.write ... should it have been out.write?

  • @priyankamonalisa2028
    @priyankamonalisa2028 8 ปีที่แล้ว

    Hi,
    Could please tell me how to do this client-server in 2 different system in same network? I tried to give the IP of server in client, but it didnt work?

  • @DirtyDan612
    @DirtyDan612 5 ปีที่แล้ว

    When I run the server I get the two statements to print but when i run the client nothing happens, any ideas why? My code is exactly the same.

  • @anwarulkaium1101
    @anwarulkaium1101 6 ปีที่แล้ว

    Hi Navin, thanks for this wonderful video. How would I transfer a List of elements from a server to client by using DataInput/OutputStream. I tried with out.write(list), it does not work. Your reply will be highly appreciated.

  • @ydtj20
    @ydtj20 3 ปีที่แล้ว

    Exception in thread "main" java.net.SocketException: Connection reset
    sir how to handle this?

  • @AYAN454
    @AYAN454 4 ปีที่แล้ว

    where do we need "out" variable then?

  • @ishajha1243
    @ishajha1243 6 ปีที่แล้ว

    Thank You Sir

  • @Onomandah
    @Onomandah 6 ปีที่แล้ว

    What was the purpose of creating a PrintWriter object??

  • @wilburtmoreno469
    @wilburtmoreno469 6 ปีที่แล้ว

    i did excatly whats in your program. and an erroe accured is says. "java.net.SocketException: connection reset"
    how can i solve this error?

    • @duff2233
      @duff2233 6 ปีที่แล้ว +1

      in client program there is a os.close(); missing after flush()... I had the same problem

    • @gouravthapa5815
      @gouravthapa5815 6 ปีที่แล้ว +1

      In client class. insert a newline character in end of your data. e.g println("Nanin Reddy
      ");
      because readLine() function need a newline character to stop reading.

  • @realprince1107
    @realprince1107 ปีที่แล้ว

    Can anybody tell where is the next video, please?

  • @hemanth6951
    @hemanth6951 8 ปีที่แล้ว +9

    hi,i am your fan from long year,but you never noticed me

  • @satadhi
    @satadhi 6 ปีที่แล้ว

    what does line 17 do ? in cient side

  • @satadhi
    @satadhi 6 ปีที่แล้ว

    why will you use opera when you have a mac ?

  • @suryabhagavan8390
    @suryabhagavan8390 7 ปีที่แล้ว

    HI, This is bhagvan. Iam getting NetworkOnMainThreadException when rnning this code. I was tried in google but there are no source. can you please tell me why this coming. give the link for referance if possible. Thank q

  • @ramzi-sah
    @ramzi-sah 5 ปีที่แล้ว +5

    7:18 nine nine nine nine mine furheur

  • @mridulmishra8166
    @mridulmishra8166 7 ปีที่แล้ว

    Hi Naveen, you are a life saver. Any plans on making creating JavaScript playlist?

  • @yuyuliang2311
    @yuyuliang2311 6 ปีที่แล้ว

    I have written the same code. But the server never connect with client, although their port are same.I have checked the code many times. But I can't find the problem yet.

  • @williamletwaba2753
    @williamletwaba2753 8 ปีที่แล้ว

    How can 1 send an XML message to the server?

  • @manish.periwal
    @manish.periwal 7 ปีที่แล้ว

    how to communicate between two remote machines?

  • @pullareddyanumula5153
    @pullareddyanumula5153 9 ปีที่แล้ว +1

    how to send file client to server

  • @sagarbathla5160
    @sagarbathla5160 5 ปีที่แล้ว

    can anyone please tell how to connect two clients using socket instead of client and server

  • @onlyforstudy7183
    @onlyforstudy7183 3 ปีที่แล้ว

    Plzz more explain about program

  • @corporateexplorer6544
    @corporateexplorer6544 7 ปีที่แล้ว

    java.net.SocketException: Connection reset
    sir please help ye exception aaa rhi h

  • @sajithkumaresan3645
    @sajithkumaresan3645 8 ปีที่แล้ว

    Hi can you please make a video regarding sockets in java script.

  • @amartyachakraborty5739
    @amartyachakraborty5739 7 ปีที่แล้ว

    " java.net.SocketException: Connection reset "
    sir i am getting this error .. what to do?

    • @arunberlin
      @arunberlin 7 ปีที่แล้ว +5

      You need to close the outputstream object and socket object
      Add these 2 lines after os.flush();
      out.close();
      s.close();

    • @susannaantinyan4595
      @susannaantinyan4595 6 ปีที่แล้ว +2

      only out.close() is enough.

    • @SourabhMaybhate
      @SourabhMaybhate 6 ปีที่แล้ว +1

      yeh..it works

  • @lololollolololo3650
    @lololollolololo3650 7 ปีที่แล้ว

    Why have you created PrintWriter object ,, out ,, and you dont use it?

    • @arunberlin
      @arunberlin 7 ปีที่แล้ว

      i have the same doubt...do u know y ?

  • @ujjalsamanta5841
    @ujjalsamanta5841 6 ปีที่แล้ว

    sir i need full courses network programming on Python. i am ready to buy it.

  • @ramsha910
    @ramsha910 7 ปีที่แล้ว +1

    sir how to sent commend also make a video

  • @mandarkulkarni5341
    @mandarkulkarni5341 2 ปีที่แล้ว

    I am sending integer then the server is getting -1

  • @myfunnyvideos8285
    @myfunnyvideos8285 9 ปีที่แล้ว

    plz upload chat application..

  • @WaqarAli-me5xg
    @WaqarAli-me5xg 3 ปีที่แล้ว

    I have copied same code,but not working

  • @vennivennela8188
    @vennivennela8188 7 ปีที่แล้ว +1

    sir,how to send message two separate computers using Sockets

  • @Sagarloona
    @Sagarloona 8 ปีที่แล้ว

    Exception connection reset on same code

  • @dragon_warrior_
    @dragon_warrior_ 4 ปีที่แล้ว

    IDK why people uses JAVA for socket Programming as there is python which is very easy and simple to use then ,I'm just here because tommorow is my exam :/

  • @akashshrestha01
    @akashshrestha01 5 ปีที่แล้ว

    Cool

  • @biswamohandwari6460
    @biswamohandwari6460 4 ปีที่แล้ว

    Socket programming don't words over WiFi

  • @ANKITSingh-eg4ww
    @ANKITSingh-eg4ww 3 ปีที่แล้ว

    Code not running, please check before uploading,
    terrible program...