当前位置: 技术问答>linux和unix
如何中断阻塞方式accept调用
来源: 互联网 发布时间:2016-04-21
本文导语: 测试代码如下: int sock = -1; void *thlsn(void *param) { int newsock = 0; struct sockaddr addr; socklen_t len; printf("start to acceptn"); newsock = accept(sock, &addr, &len); printf("accept returnedn")...
测试代码如下:
int sock = -1;
void *thlsn(void *param)
{
int newsock = 0;
struct sockaddr addr;
socklen_t len;
printf("start to acceptn");
newsock = accept(sock, &addr, &len);
printf("accept returnedn");
return NULL;
}
int main()
{
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock
int sock = -1;
void *thlsn(void *param)
{
int newsock = 0;
struct sockaddr addr;
socklen_t len;
printf("start to acceptn");
newsock = accept(sock, &addr, &len);
printf("accept returnedn");
return NULL;
}
int main()
{
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock