Network programming errors and processing under Linux

  

Error number 88 ENOTSOCK__ Socket operation on non-socket

Cause: Because there is a pair of parentheses missing when creating the socket, 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 include sockfd=socket(AF_INET, SOCK_STREAM, 0) in parentheses Get up, the correct code is 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 :111 ECONNREFUSED Connection refused

Cause: Because setting the listening port number to 13 in the program

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

Copyright © Windows knowledge All Rights Reserved