last day (15 days later) » 

2:40 PM
1
A: What is difference between socket connection and TCP connection?

Ron MaupinA TCP connection is identified by a pair of sockets (local and remote). Connecting to a remote TCP and handshaking gives you a bidirectional connection. It is like a pair of pipes (one in each direction) between the hosts, and anything going in one end of a pipe comes out the other end. RFC 793, ...

 
"socket may be simultaneously used in multiple connections. "---- how one socket used for multiple connection? Every process has unique port as well as create unique socket .... You mean one socket is for same multiple connection?
 
Yes, one socket can be used for multiple connections. If you have a web server @ 198.51.100.101, it would use a socket of that address and port 80 for all its connections of people using it with their web browsers. Each user would have a different address a port number, so all the connections on the same socket are unique.
 
Different Process has different socket or same socket?
 
TCP will only grant a port to a single application. Another application trying to use the same port already used by an application will get an error message saying that the port is already in use.
 
For same process could also have different socket because port number is dynamic. So when we create 2nd time socket for web browser then socket will be different? So how how could we say one socket can be used for multiple connections?
 
2:40 PM
As I explained, something like a web server can have many, many simultaneous connections for the one socket it is using. eack connection is identified by that socket and the remote socket. The remote sockets will all be different, so each connection identifier will be different, even with the same local socket.
 
You mean for web browser every socket may have same local socket but everyone has different remote socket?
 
No, the web server will have one socket, but the sockets of all the browsers connecting to it will all be different, meaning that the web server will have many different connections on the one socket it is using.
 
Socket connection mean 3-way handshake which follow the network/TCP stack?
 
A TCP connection is established by a three-way handshake where the connection parameters are established, and it is identified by the pair of sockets (the local IP and TCP addresses, and the remote IP and TCP addresses).
 
TCP connection follow the network stack?
 
2:40 PM
I do not know what you are asking. TCP is a transport protocol that uses a network protocol that uses a data-link protocol that uses a physical network. The transport protocols are on the network stack.
 
I asking TCP connection establishment phase in TCP header is there is no socket field but only port number is available?
 
The socket is based on the network and TCP addresses. There is no need for a socket field. A host already knows both of those for itself, and it gets those values from a different host when it receives something from the foreign host. The IP address of a foreign host is in the packet header, and the TCP address (port) will be in the segment header. Repeating that information is a different field only leads to problems and possible security risks.
 
Socket works on both layer3 and layer4? Socket is created in layer4?
 
The socket is a TCP concept. Please read the RFC, it explains how it all works. Section 2.7 explains the connection establishment. TCP creates a TCB for each connection.
 
One thing tell during connection establishment phase in TCP connection data could carry IP address in layer4 which is provided by OS?
 
2:40 PM
The IP address is in the layer-3 packet. Carrying it in a higher layer leads to problems. There are protocols that do that (TCP does not), and those protocols are broken by NAPT. Some VoIP has such problems, and trying to use it with NAPT requires the use of an external server to fix the problem of the higher-layer protocol using the private network address instead of the public address. It is a mess, but TCP does not do it that way.
 
You said socket is TCP concept, but in layer4 IP address isn't available, so how socket is created in layer4, by OS?
 
That has been answered here many times, and it is in the RFC. The host has APIs that let TCP inquire the IP address, just like there are APIs that let the application layer inquire the port number in TCP. Just because the IP address is in layer-3 does not mean it is unavailable to TCP or any layer-4 process.
 
My final question is socket is connection or concepts or address?
 
A socket is a concept, just like a connection is a concept. A host will create data structures for sockets and connections, but specific OS implementations are off-topic here.
 

last day (15 days later) »