Network: Can multiple processes listen to the same port number?

Source: Internet
Author: User
Tags set socket

We all know that a socket is a two-way communication link between two processes on a network,

Socket = IP address of a process: port number, IP address of process B: Port number

Then there is a problem is interesting, different processes can listen to the same IP address: port number?

According to the Knowledge of UNIX network programming, the service side listens to a port to experience:

1. Create socket sockets based on socket type (IPV4,IPV6, etc.)

2. Bind socket bind to specific network address and port number

3. Call listen to start listening on this socket.

UNIX provides an interface that setsockopt () can set socket options before bind, including the reuseaddr option, which indicates that multiple processes can reuse the address and port number specified in the BIND function.

It can be concluded that multiple applications (processes), including the same application multiple times, are bound to the same port for listening. Corresponding interfaces are also available in high-level languages such as C + + and net.


As you can see from some examples, sometimes when you perform Netstat-ano on a server, you may find that the same application has multiple listeners on the same port because some service-side applications may exit abnormally or not completely release the socket. However, this is also the case when you need to be able to listen to the same port again at reboot, so you need the ability to listen to the same ports repeatedly.

Network: Can multiple processes listen to the same port number?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.