錯(cuò)誤號(hào) 88 ENOTSOCK__ Socket operation on non-socket
錯(cuò)誤原因:因?yàn)樵诮ocket的時(shí)候少了一對(duì)括號(hào)導(dǎo)致,錯(cuò)誤代碼如下:
if(sockfd=socket(AF_INET, SOCK_STREAM, 0)<0)
{
cout << "socket error" << endl;
return 0;
}
正確代碼應(yīng)該是將sockfd=socket(AF_INET, SOCK_STREAM, 0)使用括號(hào)括起來,正確代碼如下
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;
}
錯(cuò)誤號(hào):111 ECONNREFUSED Connection refused
錯(cuò)誤原因:因?yàn)樵诔绦蛑袑⒈O(jiān)聽端口號(hào)設(shè)置為13導(dǎo)致
解決辦法是將端口號(hào)設(shè)置為大于1024的數(shù)字。