Strange Linux socket Problems

Source: Internet
Author: User
The strange problem of Linux socket-general Linux technology-Linux programming and kernel information. The following is a detailed description. When using a TCP Socket for Listen in Linux, a strange problem was found recently.

Accept (2) can accept a sockaddr pointer to return the address of a remote host. However, if this connection is the first time this program occurs, no data is obtained. This problem is not solved from the second time, that is, the access function follows the accept function and uses a getpeername (2) to obtain the IP address of the connected host, the connection since then does not have this problem. However, if accept (sock_fd, NULL, NULL) is used in accept to prevent accept (2) from returning the remote host address, the first getperrname function is useless.

This problem on the platform I can now test has Linux 2.4.20, glibc-2.3, Linux 2.6.18 glibc-2.3, Linux 2.6.20-21, glibc 2.7 all have this problem, I don't know if it is a socket implementation bug.

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.