socket linger

想把socket延迟关闭取消,结果不work,


反复试了几次,发现这样才行:

struct linger linger1 = {1,0};


if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (char *) &linger1, sizeof(linger1)) < 0)
{
printf("setsockopt(...,SO_LINGER,...)");
}


也就是反linger打开,但把超时设成0


打个标签,免得自己将来又忘了...


你可能感兴趣的:(socket)