On Mon, Oct 22, 2001 at 08:05:42AM -0700, Homayoun Yousefi'zadeh wrote:
> Hello All,
> 
> I have a question regarding a ping program
> in Java. I am trying to improve the performance
> of an infinite ping loop by keeping the socket
> open and using SO_KEEPALIVE option instead of
> opening and closing a client socket once every
> few seconds.

If you're willing to use JNI, you can change the keepalive interval
with the native setsockopt() call. Two options control keepalive
behavior: TCP_KEEPIDLE (when to start keepalives on an idle socket),
and TCP_KEEPINTVL (keepalive interval). You'll find those options defined
in /usr/include/netinet/tcp.h.

Whether messing with keepalives will give you the ping functionality
you really want... that's another question. Keepalive is a TCP option,
and "ping" usually implies a particular ICMP (!= TCP) protocol request
and response.

Nathan


> I have been looking at the documentation trying
> to find out how I can change the default probe
> timing of 2 hours for SO_KEEPALIVE but been out
> of luck. SO far the only implementation I know of
> that allows the SO_KEEPALIVE interval to be set
> per connection is SVR4.2.
> 
> Any hint on how I can do this on Linux relatively
> easily? Any suggestion will be greatly appreciated.
> I would also like to hear any other suggestion
> you may have for enhancing the performance of
> the ping loop as well as seeing any code snippet
> or pointer.
> 
> Thanks in advance.
> 
> HY
> 
> 
> 
> 
> ----------------------------------------------------------------------
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
> 

-- 


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to