When I try to bind socket to port 80 from program I get error, but how two browsers simultaneously could listen to same port 80 ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Browsers do not listen on port
80, HTTP servers do (although that’s just convention, you could easily have an FTP or telnet server using port80).In TCP/IP, a “session” must be unique and the session is defined as the 5-tuple
(protocol, sourceIP, sourcePort, destinationIP, destinationPort). This allows the packets to be routed correctly on the internet.Typically when a client attempts to contact a server, it specifies
0as its source port which means that the operating system assigns it an unused one. That means that the client will actually listen on that port rather than port80.So you may get a session with the properties
(TCP, mybox.com, 1101, www.microsoft.com, 80)when your browser goes out to access Microsoft’s web pages.If you find you cannot bind your server to port
80, it will most likely because you already have a server running on that port, or your program doesn’t have the required privileges to bind to that port (ports less than1024are generally considered privileged ports).Running
netstat -a(on Linux or Windows) will tell you whether a server is bound to port80. Look for a listener on port80(orhttpif it’s resolving ports to service names), something like: