Socket Programming interview Question.

Q:) Name the seven layers of the OSI Model and describe them briefly?
Answer:-
Physical Layer - covers the physical interface between devices and the rules by which bits are passed from one to another.
Data Link Layer - attempts o make the physical link reliable and provides the means to activate, maintain, and deactivate the link.
Network Layer - provides for the transfer of information between end systems across
some sort communications network.


Transport Layer - provides a mechanism for the exchange of data between end system.
Session Layer - provides the mechanism for controlling the dialogue between applications in end systems.

Presentation Layer - defines the format of the data to be exchanged between applications and offers application programs a set of data transformation services.
Application Layer - provides a means for application programs to access the OSI environment.

Q:) What is the difference between TCP and UDP?
Answer:-
TCP and UDP are both transport-level protocols. TCP is designed to provide reliable
communication across a variety of reliable and unreliable networks and internets.
UDP provides a connectionless service for application-level procedures. Thus, UDP is basically an unreliable service; delivery and duplicate protection are not
guareented.

Q:) What are advantages and disadvantages of Java Sockets.
Answer:-
Advantages of Java Sockets:
Sockets are flexible and sufficient. Efficient socket based programming can be easily implemented for general communications.
Sockets cause low network traffic. Unlike HTML forms and CGI scripts that generate and transfer whole web pages for each new request, Java applets can send only
necessary updated information.
Disadvantages of Java Sockets:
Security restrictions are sometimes overbearing because a Java applet running in a Web browser is only able to establish connections to the machine where it came
from, and to nowhere else on the network
Despite all of the useful and helpful Java features, Socket based communications allows only to send packets of raw data between applications. Both the client-side
and server-side have to provide mechanisms to make the data useful in any way.
Since the data formats and protocols remain application specific, the re-use of socket based implementations is limited.