Sockets and TCP Sockets
What is the difference between an ordinary socket and a TCP socket?. Also in a web server like IIS, how many TCP sockets can be created in a server?. I had read somewhere that when the client connects to a web server(on port 80开发者_运维知识库), the web server creates a temporary port and replies to the client on the temporary port. Is that true ?.
"socket" is a generic term for an interface created by the socket(2) system call. Sockets can operate over a variety of interfaces - TCP/IP, UDP/IP, host-local "UNIX domain sockets", etc. A TCP socket is a particular instance type.
As Andrew mentioned, socket is just an interface. Think about plug and socket; where socket is an external interface for the plug.
Now imagine a socket inside the computer and a plug coming from the outside world, plugged into that socket - that is, connected; now they would need to tell each other how they would communicate(that is, the protocol). The standard forms of protocol are TCP or UDP. See introduction to TCPIP.
A socket is defined by a protocol and an address on the host. The format of the address is specific to each protocol. In TCP/IP, the address is the combination of the IP address and port. Two sockets, one for each end of the connection, form a bidirectional communications path.
An OS can have up to 65536 ports; in windows up to 1024 are reserved by OS for itself.
Yes, it is correct that a server(including IIS) takes on the initial request and forwards the connection to a redirected port. Worth a a glimpse link. Also, see performance tuning section if you want to limit connections to IIS.
can't explain details on TCP socket vs regular socket, but you are correct about the temporary port. The socket is handed off from port 80 and communication resumes on some other free port.
this makes sense if you think about for all web servers. A ton of us are all trying access stack overflow at the same time. We all can't talk to SO server on port 80. Thus the server takes our initial request on port 80 then hands the connection off to some other port for the duration of the connection.
精彩评论