http://c.biancheng.net/view/2131.html
https://zhuanlan.zhihu.com/p/598315939?utm_id=0
- 将socket设置为非阻塞式的
https://zhuanlan.zhihu.com/p/29294059
fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL, 0) | O_NONBLOCK);
ioctl(sockfd, FIONBIO, 1); //1:非阻塞 0:阻塞
- 获取socket连接的对方地址或者本地地址
http://www.360doc.com/content/12/0121/07/71858349_1076205115.shtml
getpeername():获取连接的对方地址
gethostname():获取本地地址
0 条评论