• 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: Vincent Lubet <email@hidden>
  • Date: Thu, 4 Mar 2004 07:26:41 -0800

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
_______________________________________________
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: ioctl always returns 0
  • Next by Date: Re: ioctl always returns 0
  • Previous by thread: ioctl always returns 0
  • Next by thread: Re: ioctl always returns 0
  • Index(es):
    • Date
    • Thread