Re: Problem in Kernel Socket Read.
Re: Problem in Kernel Socket Read.
- Subject: Re: Problem in Kernel Socket Read.
- From: Terry Lambert <email@hidden>
- Date: Tue, 12 Dec 2006 21:34:31 -0800
On Dec 11, 2006, at 3:07 AM, Quinn wrote:
At 12:43 +0530 11/12/06, Nandan Nivgune wrote:
I am trying to read and write using Kernel socket in Mac os X
10.4.7; using "Kpi_socket" Header file. It performs connect &
write operation successfully while in case of reading data from
socket, it returns with
error: 35, Resource temporary unavailable.
The obvious cause for this is documented in the header:
@result 0 on success, EWOULDBLOCK if non-blocking and operation
would cause the thread to block, otherwise the errno error.
If you look in "/usr/include/sys/errno.h", you'll see that error 35
is EAGAIN which is equivalent to EWOULDBLOCK.
This will not necessarily be true forever; the proper errno for
sockets is EWOULDBLOCK, please use EWOULDBLOCK in case it gets changed
out from under you at some point.
Also, you should wean yourself off mixing up:
ENOTSUP - Operation not supported
EOPNOTSUPP - Operation not supported on socket
the second is always for sockets (except for lchown; the POSIX
standard is sort of broken for that one API). Generally EAGAIN and
ENOTSUP are private to file calls.
If you don't know what an fd you are calling is attached to (because
you don't remember from when you got it), you can always call fstat to
ask.
-- Terry
You can confirm the non-blocking status of a socket using
sock_isnonblocking. If the sock is, in fact, in non-blocking mode
and you want it to be in blocking mode, use <x-man-page://2/ioctl>
with the FIONBIO selector to set it to be blocking.
S+E
--
Quinn "The Eskimo!" <http://www.apple.com/developer/
>
Apple Developer Relations, Developer Technical Support, Core OS/
Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden