一个字,太牛了!
以前用的好好的一个socket程序,今天频繁的出错,连接失败,用perror查看发现是Interrupter System call!这是怎么回事?然后google第一篇就是Unix connect & Interrupted system call,里面一看,我靠,简直没法说了!而且还有超强的Richard Steven!
把这段代码留下来保存:
/* Start with fd just returned by socket(), blocking, SOCK_STREAM... */
while ( connect (fd, &name, namelen) == -1 && errno != EISCONN )
if ( errno != EINTR )
{
perror ("connect");
exit (EXIT_FAILURE);
}
/* At this point, fd is connected. */
connect & Interrupted System Call
最新推荐文章于 2024-08-03 11:52:06 发布