• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: ioctl always returns 0
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: ioctl always returns 0


  • Subject: RE: ioctl always returns 0
  • From: "Mahesh Vyas" <email@hidden>
  • Date: Tue, 19 Apr 2005 11:24:05 +0530
  • Thread-topic: ioctl always returns 0

If SO_KEEPALIVE is set, We have observed that when client machine is
switched off the disconnect request comees to Server is exactly after 2
hrs

We would like to reduce it, Can we do that ? How ?

-----Original Message-----
From: Vincent Lubet [mailto:email@hidden]
Sent: Monday, April 18, 2005 10:44 PM
To: Mahesh Vyas
Cc: email@hidden; Abhishek Jain
Subject: Re: ioctl always returns 0

Don't worry the value is too be treated as a boolean: 0 means offs and
anything else means on.

That you always get 8 is an implementation detail (8 correspond to the
bit field position where the information is stored in the kernel socket
data structure).

Vincent

On Apr 14, 2005, at 3:43 AM, Mahesh Vyas wrote:

>
> We tried following but it failed
> int val1 = 1;
> setsockopt(socket,SOL_SOCKET,SO_KEEPALIVE,(char*)&val1,sizeof(val1));
>
> Infact we also tried getting the SO_KEEPALIVE value using getsockopt
> before and after doing setsockopt In both the case it is coming out to

> be 8.
>
> Are we missing something ?
>
>
>
> -----Original Message-----
> From: Vincent Lubet [mailto:email@hidden]
> Sent: Wednesday, April 13, 2005 3:00 AM
> To: Mahesh Vyas
> Cc: email@hidden; Abhishek Jain
> Subject: Re: ioctl always returns 0
>
> This is normal, the TCP protocol has been designed to survive very
> long loss of connectivity so there is no idle timer by default.
>
> You should set the socket option SO_KEEPALIVE to force the networking
> stack to check the peer is responding -- see man page setsockopt(2).
> In addition you may want to use the TCP option TCP_KEEPALIVE to
> specify the idle time used when SO_KEEPALIVE is enabled.
>
> Vincent
>
> On Apr 12, 2005, at 6:44 AM, Mahesh Vyas wrote:
>
>
>> Hi
>>
>> The code below works fine if the client crashes. However, if there is

>> a power failure or a shut down of the client machine, the code
>> doesn't
>>
>
>
>> yield the desired result and the server machine is not able to detect

>> the client disconnect.
>> Could you suggest something for this?
>>
>> Rgds
>> Abhishek
>>
>>
>> -----Original Message-----
>> From: Vincent Lubet [mailto:email@hidden]
>> Sent: Thursday, March 04, 2004 8:57 PM
>> To: Mahesh Vyas
>> Cc: email@hidden
>> Subject: Re: ioctl always returns 0
>>
>>
>>
>> On Mar 3, 2004, at 10:59 PM, Mahesh Vyas wrote:
>>
>>
>>
>>> ioctl(mSocket,FIONREAD,&lDgramSize) always returns 0 irrespective of

>>> socket is closed or open.
>>> Our aim is , when client quits server should find out with above API

>>> whethe client still running or not.
>>>
>>>
>>
>> This is not the correct way to find out the peer is disconnected.
>>
>> Rather you should use recv() with the MSG_PEEK flags:
>>
>>     n = recv(mSocket, &buffer, 1, MSG_PEEK);
>>     if (n == -1)
>>         if (errno == EWOULDBLOCK)
>>             no data
>>         else
>>             other error handling
>>     else if (n == 1)
>>         data is available
>>     else if (n == 0)
>>         peer is disconnected
>>
>> Vincent
>>
>>
>>
>>
>>
>>
>>
>
>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Network mystery
  • Next by Date: Solved: Using non-ASCII chars to access servers
  • Previous by thread: Re: ioctl always returns 0
  • Next by thread: Appending to files with CFFTP
  • Index(es):
    • Date
    • Thread