4, సెప్టెంబర్ 2022, ఆదివారం

JAVA SOCKET PROGRAMMING CONCEPTS,THIS IS THE SUMMARY OF THE MY CLASS EXPLANATIONS, IT IS NOT A ALTERNATIVE OF MY LECTURE THIS IS GIVEN FOR THE ENGINEERING GRADUATES






Java Socket Programming

Java Socket programming is used for communication between the applications running on different JRE.

Java Socket programming can be connection-oriented or connection-less.

Socket and ServerSocket classes are used for connection-oriented socket programming and DatagramSocket and DatagramPacket classes are used for connection-less socket programming.

The client in socket programming must know two information:

1.       IP Address of Server, and

2.       Port number.

Here, we are going to make one-way client and server communication. In this application, client sends a message to the server, server reads the message and prints it. Here, two classes are being used: Socket and ServerSocket. The Socket class is used to communicate client and server. Through this class, we can read and write message. The ServerSocket class is used at server-side. The accept() method of ServerSocket class blocks the console until the client is connected. After the successful connection of client, it returns the instance of Socket at server-side.


1.       SERVERSIDECODE

2.       public static void main(String[] args){  

3.       try{  

4.       ServerSocket ss=new ServerSocket(6666);  

5.       Socket s=ss.accept();//establishes connection   

6.       DataInputStream dis=new DataInputStream(s.getInputStream());  

7.       String  str=(String)dis.readUTF();  

8.       System.out.println("message= "+str);  

9.       ss.close();  

10.    }catch(Exception e){System.out.println(e);}  

11.    }  

12.    }  

 

1.       CLIENT SIDE CODE

2.       try{      

3.       Socket s=new Socket("localhost",6666);  

4.       DataOutputStream dout=new DataOutputStream(s.getOutputStream());  

5.       dout.writeUTF("Hello Server");  

6.       dout.flush();  

7.       dout.close();  

8.       s.close();  

9.       }catch(Exception e){System.out.println(e);}  

10.    }  

Rif if you run the above program client send some message to server which will be displayed at server side


 

Example of Java Socket Programming (Read-Write both side)

In this example, client will write first to the server then server will receive and print the text. Then server will write to the client and client will receive and print the text. The step goes on.

1.       import java.net.*;  

2.       import java.io.*;  

3.       class MyServer{  

4.       public static void main(String args[])throws Exception{  

5.       ServerSocket ss=new ServerSocket(3333);  

6.       Socket s=ss.accept();  

7.       DataInputStream din=new DataInputStream(s.getInputStream());  

8.       DataOutputStream dout=new DataOutputStream(s.getOutputStream());  

9.       BufferedReader br=new BufferedReader(new InputStreamReader(System.in));  

10.      

11.    String str="",str2="";  

12.    while(!str.equals("stop")){  

13.    str=din.readUTF();  

14.    System.out.println("client says: "+str);  

15.    str2=br.readLine();  

16.    dout.writeUTF(str2);  

17.    dout.flush();  

18.    }  

19.    din.close();  

20.    s.close();  

21.    ss.close();  

22.    }}  

import java.net.*;  

import java.io.*;  

class MyClient{  

public static void main(String args[])throws Exception{  

Socket s=new Socket("localhost",3333);  

DataInputStream din=new DataInputStream(s.getInputStream());  

DataOutputStream dout=new DataOutputStream(s.getOutputStream());  

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));  

  String str="",str2="";  

while(!str.equals("stop")){  

str=br.readLine();  

dout.writeUTF(str);  

dout.flush();  

str2=din.readUTF();  

System.out.println("Server says: "+str2);  

}  

  dout.close();  

s.close();  

}}  

 continuous communication from the client and server side till you terminate the any of the process

CONNECTION LESS SERVICE IMPLEMENTATION IN JAVA

Java DatagramSocket and DatagramPacket

Java DatagramSocket and DatagramPacket classes are used for connection-less socket programming using the UDP instead of TCP.

Datagram

Datagrams are collection of information sent from one device to another device via the established network. When the datagram is sent to the targeted device, there is no assurance that it will reach to the target device safely and completely. It may get damaged or lost in between. Likewise, the receiving device also never know if the datagram received is damaged or not. The UDP protocol is used to implement the datagrams in Java.

Java DatagramSocket class

Java DatagramSocket class represents a connection-less socket for sending and receiving datagram packets. It is a mechanism used for transmitting datagram packets over network.`

A datagram is basically an information but there is no guarantee of its content, arrival or arrival time.

Example of Sending DatagramPacket by DatagramSocket

 

1.       //DSender.java  

2.       import java.net.*;  

3.       public class DSender{  

4.         public static void main(String[] args) throws Exception {  

5.           DatagramSocket ds = new DatagramSocket();  

6.           String str = "Welcome java";  

7.           InetAddress ip = InetAddress.getByName("127.0.0.1");  

8.            

9.           DatagramPacket dp = new DatagramPacket(str.getBytes(), str.length(), ip, 3000);  

10.        ds.send(dp);  

11.        ds.close();  

12.      }  

13.    }  

Example of Receiving DatagramPacket by DatagramSocket

 

1.       //DReceiver.java  

2.       import java.net.*;  

3.       public class DReceiver{  

4.         public static void main(String[] args) throws Exception {  

5.           DatagramSocket ds = new DatagramSocket(3000);  

6.           byte[] buf = new byte[1024];  

7.           DatagramPacket dp = new DatagramPacket(buf, 1024);  

8.           ds.receive(dp);  

9.           String str = new String(dp.getData(), 0, dp.getLength());  

10.        System.out.println(str);  

11.        ds.close();  

12.      }  

13.    }  

IF YOU EXECUTE THE ABOUVE 2 PROGRAMS 

first program sends the message to the second program

3, సెప్టెంబర్ 2022, శనివారం

poror-ramapuram signals-GUINDY, koyambedu bus terminal, DONT FIND USELESS MISTAKES , PURPUS SERVED OR NOT IS THE MOST IMPORTANT RAMU,NRI, FACTS OF LIFE

 





 THE ABOVE IS MY MANSCIPT FROM SATYANAGAR TO KOYAMBEDU FOR GOING AND COMMING BACK

GENERALLY CONFUSSION WILL COME , EVEN YOU TRAVELLED BY METRO, BUS OR BY PRIVATE TRANSPORT

UNLESS YOU USE YOUR OWN VECHICLE.

RAMU@DAYINA, MADRAS.

 

 

ANOTHER ROUTE  WITHOUT TOUCHING GUNDI FLYOUVERS 54ct bus no MTC MADRAS

 THIS IS THE ROUTE PASS THROUGH GRACE SUPERMARKET , PETROL PUMP..........

l.t,/Michal garden

Rayala Nagar

Ramapuram Ashram

Ramapuram (L.N.P. Kovil)

Ramapuram Main Road

Kalaignar Nagar West

Alwarthirunagar

Virugambakkam (Chandra Mall)

Avichi bus stand

Vadapalani Bus Stand

Thirunagar

M.M.D.A. (Arumbakkam)

C.M.B.T

Koyambedu Police Station

Vegetables Market

Koyambedu Market

 


1, సెప్టెంబర్ 2022, గురువారం

MY TRIP TO NAVALUR,MARINAMALL

 

52 min (26.0 km) via Rajiv Gandhi IT Expy/Rajiv Gandhi Salai  Fastest route now due to traffic conditions

This route has tolls. Ramapuram Tamil Nadu

Take 1st St, St Patricks Church Rd, Mettu St and N Parade Rd to Chennai - Nagapattinam Hwy/Chennai - Trichy Hwy

6 min (1.6 km)

 

Turn right onto Chennai - Nagapattinam Hwy/Chennai - Trichy Hwy

 

Pass by Head Post Office, St Thomas Mt (on the left in 900 m)

3 min (1.6 km)

Follow 100 Feet Rd and Velachery Rd/Velachery - Tambaram Main Rd to 200 Feet Radial Rd/Pallavaram-Thuraipakkam Rd in Pallikaranai Marshland

13 min (7.0 km)

https://maps.gstatic.com/consumer/images/icons/2x/turn_left_grey800_18dp.png

Turn left onto 100 Feet Rd

 

Go through 1 roundabout

 

Pass by Sai Maaruthy (on the left in 850 m)

1.2 km

https://maps.gstatic.com/consumer/images/icons/2x/straight_grey800_18dp.png

Continue straight to stay on 100 Feet Rd

2.5 km

https://maps.gstatic.com/consumer/images/icons/2x/turn_left_grey800_18dp.png

Turn right toward 100 Feet Rd

29 m

https://maps.gstatic.com/consumer/images/icons/2x/turn_left_grey800_18dp.png

Turn left toward 100 Feet Rd

41 m

https://maps.gstatic.com/consumer/images/icons/2x/straight_grey800_18dp.png

Continue onto 100 Feet Rd

1.2 km

https://maps.gstatic.com/consumer/images/icons/2x/merge_grey800_18dp.png

Use any lane to take the ramp onto Velachery Rd/Velachery - Tambaram Main Rd

 

Pass by the petrol pump (on the right in 850 m)

1.8 km

https://maps.gstatic.com/consumer/images/icons/2x/merge_grey800_18dp.png

Turn left onto the ramp to MDR622

Street View

120 m

https://maps.gstatic.com/consumer/images/icons/2x/straight_grey800_18dp.png

Continue onto MDR622

160 m

Drive to Rajiv Gandhi IT Expy/Rajiv Gandhi Salai in Navalur

27 min (15.8 km)

Navalur Toll Plaza

Navallur Toll Booth, Rajiv Gandhi Salai, Navalur, Tamil Nadu 603103

 

INHERITENCE,METHOD OVERRIDING,SUPER,POLYMORPHISIM IN JAVA


 

SUMMARY OF METHODS IN JAVA, METHOD OVERLOADING , STATIC METHODS, NESTING OF METHODS IN JAVA