The meaning of Inaddr_any in Linux network programming

Source: Internet
Author: User

inaddr_any OptionsNetwork programming commonly used in the bind function, you need to bind the IP address, you can set Inaddr_any Inaddr_any is the specified address is 0.  0.0.  0 address, which in fact represents an indeterminate address, or "all addresses", "arbitrary addresses". That is to say that all the IP, because some of the machine more than one network card, multi-card case, this is the meaning of all network card IP address. For example, a computer has 3 network cards, respectively connected to three networks, then this computer has 3 IP addresses, if an application needs to listen to a port, then he should listen to which network card address port? If binding a specific IP address, you can only listen to the IP address you set up the network card port, the other two network card can not listen to the port, if I need three network cards are listening, then need to bind 3 IP, it is equal to the need to manage 3 sockets for data exchange, Wouldn't that be tedious? so you just have to bind Inaddr_any, manage a socket on the line, regardless of the data is from which network card, as long as it is bound to the port number over the data, can be received. of course, the inaddr_any option cannot be used when client connect. You must indicate which server IP you want to connect to.

Original http://blog.csdn.net/scottly1/article/details/24416007

The meaning of Inaddr_any in Linux network programming

Related Article

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.