Sockets: An object created by any networked application which contains 'data and address*' details to be sent to another program running on another machine elsewhere via wireless or wired infrastructure.
Eg: In case of Java, Socket is part of Java's Networking API(java.net.* package) which knows how to talk to machine's Network Stack(TCP/IP) to send and receive data.
Network Stack: Its a software+hardware infrastructure specific to a computer. The software component is usually implemented by machine's OS.
data and address*:
Data -> Data from source program.
Address -> Host and Port details of the destination program.
Q) When can we say a connection is established between a server and a client?
Ans) Many imagine or believe that a connection is physical wire or wireless connection. Or some might think it's specific to machine's protocol layer. But this is a pure misconception. Connection is purely abstract and conceptual. Below is how it's supposed to be perceived.
Similar to how a socket object is created at source program, if a new socket object is created(to receive the data) at the destination program on the destination machine upon a receiving a request from source, then we can say a connection is established. So, in an abstract way connection means creation of client and server specific socket objects. The data transmission between source and destination programs over 'that connection' happens usually but not restricted to first via TCP(But also UDP, SCTP etc - Transport Layer protocols) then to IPv4(but also IPv6, ICMP etc - Internet layer protocols) then to ARN(but also NDP, OSN etc - Link Layer) and so on down through TCP/IP stack protocol layer. Above all the layers is the Application Layer. Hence, 'that connection' is named based on the application layer protocol...
Eg:
1) HTTP Connection if the client and server uses HTTP (Web applications use this)
2) SMTP Connection if the client and server uses SMTP (e-Mail applications use this)
etc,.
Note: Protocols used by Applications - Web Application, Mail Applications, Chat applications etc,. any user application - are called Application Layer protocols. But here is the catch. Sometimes applications may skip the Application Layer and directly communicate starting from Transport layer.
Now, look at the below diagram showing how the above explained Sockets and Network Stack work exactly in a communication process between a Http Client and Http Server. Clearly indicated who does what - that of Server and Client.
Eg: In case of Java, Socket is part of Java's Networking API(java.net.* package) which knows how to talk to machine's Network Stack(TCP/IP) to send and receive data.
Network Stack: Its a software+hardware infrastructure specific to a computer. The software component is usually implemented by machine's OS.
data and address*:
Data -> Data from source program.
Address -> Host and Port details of the destination program.
Q) When can we say a connection is established between a server and a client?
Ans) Many imagine or believe that a connection is physical wire or wireless connection. Or some might think it's specific to machine's protocol layer. But this is a pure misconception. Connection is purely abstract and conceptual. Below is how it's supposed to be perceived.
Similar to how a socket object is created at source program, if a new socket object is created(to receive the data) at the destination program on the destination machine upon a receiving a request from source, then we can say a connection is established. So, in an abstract way connection means creation of client and server specific socket objects. The data transmission between source and destination programs over 'that connection' happens usually but not restricted to first via TCP(But also UDP, SCTP etc - Transport Layer protocols) then to IPv4(but also IPv6, ICMP etc - Internet layer protocols) then to ARN(but also NDP, OSN etc - Link Layer) and so on down through TCP/IP stack protocol layer. Above all the layers is the Application Layer. Hence, 'that connection' is named based on the application layer protocol...
Eg:
1) HTTP Connection if the client and server uses HTTP (Web applications use this)
2) SMTP Connection if the client and server uses SMTP (e-Mail applications use this)
etc,.
Note: Protocols used by Applications - Web Application, Mail Applications, Chat applications etc,. any user application - are called Application Layer protocols. But here is the catch. Sometimes applications may skip the Application Layer and directly communicate starting from Transport layer.
Now, look at the below diagram showing how the above explained Sockets and Network Stack work exactly in a communication process between a Http Client and Http Server. Clearly indicated who does what - that of Server and Client.
![]() |
Client - Server communication via TCP/IP with the help of Sockets |