lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Re: [lwip] API to Read n bytes of data (without loss aka TC


From: Adam Dunkels
Subject: [lwip-users] Re: [lwip] API to Read n bytes of data (without loss aka TCP)
Date: Wed, 08 Jan 2003 21:51:48 -0000

Hi!

On Tuesday 23 October 2001 10:14, you wrote:
> Hi,
> What kind of code modifications need to be done if I want to implement an
> api that would read n bytes of data.
>
> I understand that in lwIP we receive whatever gets stored in the mailbox at
> one go.
>
> Do we need to do major architectural rethinking to accommodate this API?

There should be no need to do any architectural rearrangements for this. It 
could (should?) be implemented as another layer on top of the netconn_recv() 
function. A good place for this could be the implementation of the read() 
functin in the BSD sockets library (the file src/api/socket.c in the latest 
CVS code).

I envision an implementation such as this:

char buffer[n];
int read_bytes = 0;

while(read_bytes < n) {
   buf = netconn_recv(conn);
   netbuf_copy(&buffer[read_bytes], buf, n - read_bytes);
   read_bytes += netbuf_len(buf);
   netbuf_delete(buf);
}

Additional checks must be added so that any remaining bytes of the netbuf is 
remembered to the next call to the read() function.

/adam
-- 
Adam Dunkels <address@hidden>
http://www.sics.se/~adam
[This message was sent through the lwip discussion list.]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]