• 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: Justin Walker <email@hidden>
  • Date: Thu, 4 Mar 2004 08:53:43 -0800

On Wednesday, March 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.

Your terminology is confused. You will get EBADF in errno (and a -1 as a return value) if you called ioctl on a 'closed' socket (file descriptor).

You cannot tell whether the client is still running. It's not possible. You may be able to determine that the remote end has closed his end of the connection, using the trick that Vincent mentions in his response, but that doesn't always work.

A fine example is Windows programs from not too long ago. There was no "cleanup-on-exit" support in some versions of Windows, so programs would quit without closing connections, the OS would leave the connections open, and your end would be stuck with an open connection and no way to close it.

In addition there are the problems of client machines crashing, and the ubiquitous back-hoe operator that is the bane of network cable installers.

In short, you can't rely on the system for this kind of information - your application has to protect itself (that is what timeouts are for).

Regards,

Justin

--
/~\ The ASCII Justin C. Walker, Curmudgeon-at-Large
\ / Ribbon Campaign
X Help cure HTML Email
/ \
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.


References: 
 >ioctl always returns 0 (From: Mahesh Vyas <email@hidden>)

  • Prev by Date: Re: ioctl always returns 0
  • Next by Date: TN 1145 - Listing 8
  • Previous by thread: Re: ioctl always returns 0
  • Next by thread: FW: ioctl always returns 0
  • Index(es):
    • Date
    • Thread