Re: poll and tcp sockets defect



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.
.



Relevant Pages

  • TOE brain dump
    ... (TCP Offload Engines). ... functionality in the main kernel, on a separate piece of hardware ... TOE will not be available to projects modifying the stack, ... tied to specific NICs (I've discussed some issues when ...
    (Linux-Kernel)
  • Re: How to tell if a firewall alert is suspicious or not
    ... > WHY this SBCGlobal DNS server would be contacting Adobe Acrobat on port ... They have to parts, a kernel and the userland, in which programs, which are ... With Internet Protocol and TCP it is so, that any network interface in the ... To initiate a TCP connection, first the server has to "listen" on a port. ...
    (comp.security.firewalls)
  • kernel 2.6.18-92.1.6 produces errors when using nfs and nis
    ... kernel 2.6.18-53.1.21.el5, with no change to any conf files when I switch ... The problem is that when the nfs service starts I get the following error ... 100000 2 tcp 111 portmapper ... 100000 2 udp 111 portmapper ...
    (Linux-Kernel)
  • RE: Linux 2.4.27 SECURITY BUG - TCP Local (probable Remote) Denial of Service
    ... > is absolutely nothing the kernel can do about it. ... > It's a resource leak, ... This is how TCP works. ... and read the bug before you comment. ...
    (Linux-Kernel)
  • Re: Setting custom TCP header options
    ... I had a feeling i may need to get into the kernel for ... Tejas Kokje wrote: ... available for the options in the TCP header? ... Even if setsockoptAPI provided a way to set custom TCP option, ...
    (comp.os.linux.networking)