Re: poll and tcp sockets defect
- From: Drago <kmakaron11@xxxxxxxxx>
- Date: Sat, 13 Jun 2009 05:22:38 -0700 (PDT)
On Jun 13, 12:16 am, David Schwartz <dav...@xxxxxxxxxxxxx> wrote:
On Jun 12, 7:23 am, Drago <kmakaro...@xxxxxxxxx> wrote:
Hello I try to use the following code, but it seems not working, on a
connected socket (sock) i do:
struct pollfd input_fd;
int a=1;
setsockopt(sock,SOL_SOCKET,SO_KEEPALIVE,&a,sizeof(a));
a=1;
setsockopt(sock,SOL_TCP,TCP_KEEPIDLE,&a,sizeof(a));
a=1;
setsockopt(sock,SOL_TCP,TCP_KEEPINTVL,&a,sizeof(a));
a=1;
setsockopt(sock,SOL_TCP,TCP_KEEPCNT,&a,sizeof(a));
input_fd.fd = sock;
input_fd.events = POLLIN | POLLOUT;
input_fd.revents = 0;
int p=poll(&input_fd, 1,-1);
I pull the LAN plug to the remote computer, but nothing happens. The
kernel seems to be sleeping in poll syscall. Is this desired
behaviour, or it is a defect?
I use linux 2.6.29.4.
Thanks.
TCP just does not do what you're trying to get it to do.
If TCP doesn't do what you want, don't use it. But trying to turn TCP
into something other than what it is always leads to nothing but pain.
DS
I am missing your point here. I have read that actually Linux kernel
can use TCP trick to "ping" the other side.
I just set sock options to most "strict" values, and I expect poll to
return value of 1 , and POLLERR in input_fd.revents.
Do you mean that it does not work quite like that?
Thanks.
.
- Follow-Ups:
- Re: poll and tcp sockets defect
- From: David Schwartz
- Re: poll and tcp sockets defect
- References:
- poll and tcp sockets defect
- From: Drago
- Re: poll and tcp sockets defect
- From: David Schwartz
- poll and tcp sockets defect
- Prev by Date: Re: poll and tcp sockets defect
- Next by Date: 6to4 - can't ping 192.88.99.1?
- Previous by thread: Re: poll and tcp sockets defect
- Next by thread: Re: poll and tcp sockets defect
- Index(es):
Relevant Pages
|