Network interface in Linux kernel

Hi,
I wrote some network modules to 2.6.x Linux kernel.
Im useing sock_recvmsg / sock_sendmsg (linuxsrc/include/linux/net.h ) interface to
receiving and sending data in TCP mode.

Im cooperating with HTTP protocol and I have a question.

Supose that I have buffer[100]
I have connection client - server WWW ( my application )
Client want to send 2023 bytes to me.

How can I check whether there ara any data to receive. I mean
if I call sock_recvmsg once ( I receive only 100 bytes ) are there any possibility to check
whether should I call again this function If yes how can I do this.

Thx for helping forward and sorry for my english :wink:

I think you should call to sock_recvmsg() several times in a loop.

Why do you want to do this in kernel space instead of user space??

ivan.

Ok, loop is simulating a "keep-alive" tcp conection but I don't want to do in way like this.
I want to create one to one connection this mean one tcp connection for one HTTP request and response so I cant check ( parse ) HTTP header.

If HTTP request header contains field with size of itself then there is no problem but
in HTTP request header there is no field like this therefor I dont know when stop(break) the loop.

Mmmmm it looks like the end of header are magick chars \r\n\n or somethig like this Maybe I can solve my simple problem with this

char buf1 = 0;
char buf2 = 0;
char buf3 = 0;

do {
   buf1 = buf2;
   buf2 = buf3;
   sock_recvmsg( buf3 )
}
while( buf1='\r' && buf='\n' && buf3='\n' )

but question is: Is this optimal for HTTP header I mean reading char by char?

PS
"Why do you want to do this in kernel space instead of user space?? "

I get this question minimum once a day :wink:
I want to learn this network interface inside a kernel.