Monday, March 1, 2021

Socket Programming

 👉    What is a socket?

            *    A socket is an object created by the operating system to communicate with the ports in the                      network.
            *    Its is a logical construct.

 👉    What is the difference between socket and ports?

            *    A ports is a acting like a door or window of a particular network, while a socket is a object                      created by the OS  that communicates with the ports.
            *    Ports are physical construct while the sockets are logical construct.

 👉    What is the types of sockets?

            *    TCP Sockets    :    Connection oriented and reliable.
            *    UDP Sockets    :    Not connection oriented and non-reliable.

 👉    Explain on TCP Sockets and UDP Sockets?

            *    TCP Sockets are used in the reliable application          Eg    :    Email, http
            *    UDP Sockets are used in non-reliable application        Eg    :    Streaming applications

            *    In TCP Sockets one application is assigned to one particular socket.
            *    In UDP Sockets many applications are assigned to one particular socket.

 👉    Explain the connection establishment process between client and server using            the TCP Sockets?

            

            *    The client consists of the client socket.
            *    The server consists of welcome socket and the connection socket.
            *    The client is an active entity while the server is a passive entity.
            *    The client sockets initiates connection while communicating with the Welcome socket in the                   server.
            *    The Welcome server is responsible to accept the client.
            *    Once the client is accepted then the client socket starts communication between the                                  connection socket in the server.
            *    In the meantime, the welcome socket becomes free and wait for other client processes.

 👉    What is blocking in sockets?

            *    Blocking means no other client is able to access while a particular client got accepted.
            *    The other client processes has to wait until the socket becomes vacant.
            *    A solution for this is Multi-threaded programming.

 👉    Java socket programming.

            *    The java.net and above supports socket programming.
            *    To use socket programming in java , the below should be imported.
                        import java.net.*
            *    Simple chat applications can be constructed using the socket programing.

 👉    Java socket programming classes.

            1.    Inet Address class.
            2.    Socket.
            3.    Server Socket.
            4.    Datagram Socket.
            5.    Datagram Packet.

            *    The yellow colored ones belong to TCP Sockets.
            *    The red colored ones belong to UDP Sockets.


No comments:

Post a Comment

Monolithic vs Microservices

👉     Monolithic Architecture. *     Monolithic architecture was there before Microservices came into action.  *     All functionalities or...