Re: [NKE]socket_receive
Re: [NKE]socket_receive
- Subject: Re: [NKE]socket_receive
- From: Terry Simons <email@hidden>
- Date: Thu, 13 Mar 2008 06:36:52 -0400
I'm not 100% sure about that error code with an NKE, but it sounds
like your socket is set up non-blocking. EWOULDBLOCK in many (all?)
unix variants means that there wasn't anything to read, and the call
would have had to block to wait for data.
This isn't really an error. It simply means that you should try
reading again later.
In a normal application this might be handled by attempting to read,
and then sleeping for some small amount of time if EWOULDBLOCK is
received, then atempting to read again. Sleeping is necessary to
avoid pegging the CPU, but I'm not sure what the recommendation would
be in an NKE.
- Terry
Sent from my iPhone
On Mar 13, 2008, at 1:42 AM, James Chan <email@hidden> wrote:
Hi all,
I follow the document "Network Kernel Extensions Programming Guide"
to trying create a kernel mode socket to send/receive data. I write
a simple code like "Listing 2-1". Now, I can send out data with
using "sock_send", but I can not receive data. (I can capture the
respond packet from the network with Ethereal.)
I try to read data with using "sock_receivembuf" in the callback
function, but it return EWOULDBLOCK.
After I got EWOULDBLOCK, I retry sock_receivembuf again, it still
return EWOULDBLOCK.
After 5 seconds, I close the socket (sock_close), the callback
function will be called twice.
The first time sock_receivembuf return 0, and the data length is
correct.
The second time, sock_receivembuf return 0, length =0,
So, I confuse with the EWOULDBLOCK status.
If I retry , it still return EWOULDBLOCK status.
If I abort and return, there are no more callback function execute
until I close socket.
Does anybody know the callback function will be trigger in what kind
of condition??
How to handle the EWOULDBLOCK. status??
Regards,
James Chan
--
James Chan
Software Engineer
Elitesilicon
_______________________________________________
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
_______________________________________________
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