Networking Forums

Networking Forums > Computer Networking > Linux Networking > poll and tcp sockets defect

Reply
Thread Tools Display Modes

poll and tcp sockets defect

 
 
Drago
Guest
Posts: n/a

 
      06-12-2009, 02:23 PM
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.
 
Reply With Quote
 
 
 
 
Rick Jones
Guest
Posts: n/a

 
      06-12-2009, 06:10 PM
Drago <(E-Mail Removed)> 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?


Are you sure that your setsockopt() calls aren't returning -1 and
setting errno? The code to do it isn't visible above - you are
actually connecting the socket to something?

rick jones
--
The computing industry isn't as much a game of "Follow The Leader" as
it is one of "Ring Around the Rosy" or perhaps "Duck Duck Goose."
- Rick Jones
these opinions are mine, all mine; HP might not want them anyway...
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
 
Reply With Quote
 
Rick Jones
Guest
Posts: n/a

 
      06-15-2009, 09:31 PM
Drago <(E-Mail Removed)> wrote:
> Yes, this is just a code fragment, and I removed checking return
> statements to produce more clear source.
> All of the setsockopt calls return 0. The sock is actually connected
> and data is read, until plugging the lan cable.
> After that poll just sleeps.


What does tcpdump show you the system trying to do - for example with
the connection idle but the cable connected, does it show the
keepalive probes being sent when you were expecting them to? I'm
wondering if perhaps there is some silent bounds conformance happening
to the values you provide in the setsockopt() calls for the idle time
before keepalives and how often and how many should be sent.

rick jones
--
No need to believe in either side, or any side. There is no cause.
There's only yourself. The belief is in your own precision. - Joubert
these opinions are mine, all mine; HP might not want them anyway...
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OT poll: who's she gonna do? IceMountainWater Broadband 0 07-06-2007 02:04 AM
Straw Poll... Gaz. Broadband 7 04-10-2006 08:04 PM
Linksys WRT54GS possible defect. Anyone see this? Richard Forester Network Routers 3 12-22-2004 12:42 AM
VPN Poll Rick Windows Networking 2 02-12-2004 02:41 PM
Printserver poll Dwayne Allen Wireless Internet 0 12-06-2003 02:00 PM



1 2 3 4 5 6 7 8 9 10 11