https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wsk/nc-wsk-pfn_wsk_receive
So I am using winsock kernel to do a simple data transfer with my other program in python. My question is how exactly am I supposed to know how much data I am to receive? Is not this data required when I make a call to IoAllocateMdl(). So how am I supposed to know how much data is coming in with the call to WskReceive().
I looked over https://github.com/Microsoft/Windows-driver-samples/blob/master/network/wsk/echosrv/wsksmple.c#L515 and it seems to be a fixed size?
I am new to kernel mode development so I am wondering if I am possibly mistaken on anything?
patrickdaniel wrote:
https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wsk/nc-wsk-pfn_wsk_receive
So I am using winsock kernel to do a simple data transfer with my other program in python. My question is how exactly am I supposed to know how much data I am to receive? Is not this data required when I make a call to IoAllocateMdl(). So how am I supposed to know how much data is coming in with the call to WskReceive().
You don’t, exactly the same as with a user-mode socket. It’s just like
calling “recv”. You pass it a buffer, and it will as much as it can.
@Tim_Roberts how then can I get all the data together rather then just some part?
patrickdaniel wrote:
@Tim_Roberts how then can I get all the data together rather then just some part?
This is just an inherent part of working with TCP. It’s a streaming
protocol. Unlike UDP, things don’t come in fixed-sized packets. You
have to keep reading until you get your “end of line” signal. For
line-oriented protocols, you look for a newline. Some protocols send a
“size” in the first few bytes. If you don’t have any identifiable “end”
signal, then you’ll have to handle a time out.
Note that this is not unique to kernel mode. It’s true for TCP everywhere.
@Tim_Roberts said:
patrickdaniel wrote:
@Tim_Roberts how then can I get all the data together rather then just some part?
This is just an inherent part of working with TCP. It’s a streaming
protocol. Unlike UDP, things don’t come in fixed-sized packets. You
have to keep reading until you get your “end of line” signal. For
line-oriented protocols, you look for a newline. Some protocols send a
“size” in the first few bytes. If you don’t have any identifiable “end”
signal, then you’ll have to handle a time out.
Note that this is not unique to kernel mode. It’s true for TCP everywhere.
I understood, thanks I have looked through the documentation and Have figured it out.