Computer Network Lab | VTU | Program 8 - UDP Socket Programming

Поділитися
Вставка
  • Опубліковано 9 лис 2024

КОМЕНТАРІ • 24

  • @roopamam7005
    @roopamam7005  4 роки тому +14

    //UDP Sever
    import java.net.*;
    import java.net.InetAddress;
    class UDPServer
    {
    public static void main(String args[])throws Exception
    {
    DatagramSocket serverSocket = new DatagramSocket(9876);
    byte[] receiveData=new byte[1024];
    byte[] sendData=new byte[1024];
    while(true)
    {
    System.out.println("Server is Up");
    DatagramPacket receivePacket=new DatagramPacket(receiveData,receiveData.length);
    serverSocket.receive(receivePacket);
    String sentence=new String(receivePacket.getData());
    System.out.println("RECEIVED:"+sentence);
    InetAddress IPAddress=receivePacket.getAddress();
    int port=receivePacket.getPort();
    String capitalizedSentence=sentence.toUpperCase();
    sendData=capitalizedSentence.getBytes();
    DatagramPacket sendPacket=new
    DatagramPacket(sendData,sendData.length,IPAddress,port);
    serverSocket.send(sendPacket);
    }
    }
    }
    //UDP Client
    import java.io.*;
    import java.net.*;
    import java.net.InetAddress;
    class UDPClient
    {
    public static void main(String[] args)throws Exception
    {
    BufferedReader inFromUser=new BufferedReader(new InputStreamReader(System.in));
    DatagramSocket clientSocket=new DatagramSocket();
    InetAddress IPAddress=InetAddress.getByName("localhost");
    byte[] sendData=new byte[1024];
    byte[] receiveData=new byte[1024];
    System.out.println("Enter the sting to be converted in to Upper case");
    String sentence=inFromUser.readLine();
    sendData=sentence.getBytes();
    DatagramPacket sendPacket=new
    DatagramPacket(sendData,sendData.length,IPAddress,9876);
    clientSocket.send(sendPacket);
    DatagramPacket receivePacket=new DatagramPacket(receiveData,receiveData.length);
    clientSocket.receive(receivePacket);
    String modifiedSentence=new String(receivePacket.getData());
    System.out.println("FROM SERVER:"+modifiedSentence);
    clientSocket.close();
    }
    }

    • @gouthamir1807
      @gouthamir1807 3 роки тому +4

      While executing on eclipse, I get an error when I run server code saying address already in use, line number 9
      Can you help me out mam

    • @roopamam7005
      @roopamam7005  3 роки тому +6

      change your Port number!

    • @pranav288
      @pranav288 2 роки тому

      @@gouthamir1807 you my college senior

  • @sangeetag7684
    @sangeetag7684 Рік тому

    Mam did my exam very well coz of ur videos Thanks :)

  • @manjunathsmanju3857
    @manjunathsmanju3857 3 роки тому +5

    ಮೇಡಂ transformation of sentence ಬಗ್ಗೆಯೂ ಸ್ವಲ್ಪ ಹೇಳಿಕೊಡಿ, ನೀವು ತುಂಬಾ ಚೆನ್ನಾಗಿ ಅರ್ಥ ಮಾಡುಸ್ತಿರಿ it's my request also 🙏

  • @abcdeftanutanu2187
    @abcdeftanutanu2187 3 роки тому +2

    thank you so much i learnt udp socket programming

  • @nirishab8016
    @nirishab8016 3 роки тому +4

    Thank you for this video ma'am.It helped me a lot.
    Ma'am can upload the computer networks theory video also...

  • @Deemastories
    @Deemastories 2 роки тому +2

    Thanks a Lot ❤❤🙏🙏🙏mam Really I was in Need With it.

  • @archanac2411
    @archanac2411 3 роки тому +2

    Thank you very much madam its helps me a lots madam

  • @VijayKumar-br7ow
    @VijayKumar-br7ow 3 роки тому +2

    I really appreciate it 👍.

  • @chandansharma6849
    @chandansharma6849 3 роки тому +2

    Thankyou so much mam😊😊

  • @gouthamir1807
    @gouthamir1807 3 роки тому +2

    Thanks a lot ma'am

  • @captain_8231
    @captain_8231 3 роки тому +1

    Thank you soo much... Helps a lot✌️

  • @hemagowda3313
    @hemagowda3313 3 роки тому +2

    Thank you mam pls upload program 9 Tcp/Ip.

  • @chandana.bchandana.b8981
    @chandana.bchandana.b8981 3 роки тому +2

    Please put a 5th standered computer lesson mam

  • @Dinesh_Kumar23
    @Dinesh_Kumar23 4 роки тому +1

    Thanks mam

  • @jaideeplobo6096
    @jaideeplobo6096 3 роки тому +3

    Mam so much headache for the exam 😭😭😭

  • @jaideeplobo6096
    @jaideeplobo6096 3 роки тому +2

    Mam wether execution is compulsory to pass the exam?
    Please reply

    • @roopamam7005
      @roopamam7005  3 роки тому +1

      :) According to rules YES! but ofcourse depends on your examiner

    • @jaideeplobo6096
      @jaideeplobo6096 3 роки тому +4

      @@roopamam7005 Mam I both program executed in the lab, I'm very happy now, thanks for these videos :)

    • @roopamam7005
      @roopamam7005  3 роки тому +1

      Thats great :)