WskSend/WskReceive Explanation

Hi,

I’m implementing a socket application to send and receive data over socket connection so need some clarifications.
WskSend/WskReceive documentation is not enough to understand how much length to pass to send or receive one command buffer in TCP Byte Stream.

When I trigger WskReceive then how much bytes I receive in one shot??
Is there any specifications for max or min data size received??
How I can decide how much data buffer I’ve to allocate for triggering WskReceive??

In read case, TCP stream may be having data buffer filled for many commands in asynchronous I/O. So here how much buffer length should I pass so that I don’t receive data of other commands i.e. I should get data bytes of exactly any one particular command only. Since I don’t know how much data is there in TCP stream for one command and how much for others. All data bytes are continuously in TCP Stream.

Host reads data with 16KB-size (Command C1)
Host reads data with 10KB-size (Command C2)

So now out of these 3-Scenerios:

1. In order and in exact packet size of command data size
=============C1===============================C2=============
*								*							*
*			16KB-Data			*			10KB-Data		*
*								*							*
=============================================================
							OR
2. Out of order and in exact packet size of command data size
=============C2===============================C1=============
*						*									*
*			10KB-Data	*			16KB-Data				*
*						*									*
=============================================================
							OR
3. Out of order and in different packet size than the command data size
========C1===========C2===================C1===========C2====
*					*				*			   *	    *
*	 10KB-Data		*  8KB-Data 	*  6KB-Data	   *2KB-Data*
*					*				*			   *	    *
=============================================================

Here for all WskReceive with a particular IRP, I’m using WSK_FLAG_WAITALL to get the completion routine only after buffer is completely filled.
Now here we have two scenerios:

  1. What if WskReceive buffer length is less than actual data length of the command, then what’s the exact no of bytes filled in buffer.
    e.g. WskReceive buffer size is 10KB for Command C1:

========C1===========C2===================C1===========C2====
*					*				*			   *	    *
*	 10KB-Data		*  8KB-Data 	*  6KB-Data	   *2KB-Data*
*					*				*			   *	    *
=============================================================

I'll get 10KB data of C1 then need to trigger one more Read Command with 6KB buffer size.
Now whether I'll get 6KB data of Command C1 (Irp Used here is same as C1) or whatever available in TCP stream i.e. 6KB data of C2 available in stream??
  1. What if WskReceive buffer length is more than actual data length of the command, then what’s the exact no of bytes filled in buffer
    e.g. WskReceive buffer size is 16KB for Command C1:

========C1===========C2===================C1===========C2====
*					*				*			   *	    *
*	 10KB-Data		*  8KB-Data 	*  6KB-Data	   *2KB-Data*
*					*				*			   *	    *
=============================================================

Now here, Whether I'll get 16KB data (10KB of C1 + 6KB of C2) or (10KB + 6KB of C1)???


One more flag is there in WskReceive: WSK_FLAG_DRAIN. What's the expectation if using this falg..??

It would be helpful if any one clears these doubts.