FW: ioctl always returns 0
FW: ioctl always returns 0
- Subject: FW: ioctl always returns 0
- From: Navin Sharma <email@hidden>
- Date: Wed, 10 Mar 2004 11:53:57 +0530
Our server is running on Mac machine and Windows client does not come to
know whenever server (on Mac) crashes or forcedly quit. To determine at
windows end whether, server is still up and working we tried to use ioctl,
getpeername, recv(as suggested in prev. mail), getsockname API's, but they
didn't worked for us. Is there any problem/issue with cross-platform
communication? Since, our Mac Clients come to know about server state using
getpeername API call.
-----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
_______________________________________________
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.