Windows Sockets: Port and socket address

Source: Internet
Author: User

This article describes the terms "Port" and "Address" used in Windows Sockets ". Port

A port identifies a unique process. A process can have a service. In the current context, the port is associated with an application that supports Windows Sockets. The reason for association is to uniquely identify each Windows Sockets application so that multiple Windows Sockets applications can run simultaneously on one computer.

Some ports are reserved for public services (such as FTP. Do not use these ports unless you are providing such public services. The Windows Sockets specification details these reserved ports. The WINSOCK. H file also lists these ports.

If you want Windows Sockets DLL to select an available port for you, pass 0 as the port value. MFC selects a port value greater than the decimal number 1,024. You can call the CAsyncSocket: GetSockName member function to retrieve the port value selected by MFC. Socket address

Each socket object is associated with an Internet Protocol (IP) address on the network. This address is usually a computer name, such as "ftp.microsoft.com", or a number separated by dots, such as "128.56.22.8 ".

When you are seeking to create a socket, you do not need to specify your own address.

Note:A computer may have multiple NICs (or applications may run on such computers one day), and each Nic represents a different network. In this case, you may need to provide an address to specify which Nic the socket will use. This will inevitably become an advanced usage and may cause portability problems.

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.