Error and processing of network programming in Linux

Source: Internet
Author: User
Tags error code socket socket error port number

Error number enotsock__ Socket operation on Non-socket

Cause of the error: because a pair of parentheses is missing when the socket is created, the error code is as follows:

if (Sockfd=socket (af_inet, sock_stream, 0) <0)
{
cout << "Socket error" << Endl;
return 0;
}
The correct code should be to enclose the sockfd=socket (af_inet, Sock_stream, 0) in parentheses, with the correct code as follows

if (<span style= "color: #ff0000;" > (</span>sockfd=socket (af_inet, sock_stream, 0) <span style= "color: #ff0000;" >) </span><0)
{
cout << "Socket error" << Endl;
return 0;
}

Error number: econnrefused Connection refused

Cause of error: Because the listener port number is set to 13 in the program, causing

The workaround is to set the port number to a number greater than 1024.

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.