Hi Burak, I'm not aware of any way how to enforce such behaviour on libuv but what you can do is to process incoming data the way you want in the read_cb. You can buffer or process the incoming data so that you call whatever callback you need when you have data for it, i.e. after reading the 1st 4 bytes you call your callback and then once you have the tail in the buffer call the other callback. Basically just add one more layer which will do whatever logic you need.
Vilibald PS: I assume that your `packet` is usually more than the one network packet because otherwise you usually get the whole packet at once in one callback, not that it is guaranteed but it behaves this way. > Hello, > > I am very sorry for disturbing people at here, however based on my > research > i cant find a good way to parse the following packet with libuv. > > I am porting a tcp server to libuv based one (C based program). However > the > data i want to read from the client is prefixed with static data and the > length. > > 0x11 0x22 0x0 0x0 (size of packet) PACKET DATA 0x22 0x11 > > I want my read callback to be executed after 4 bytes have been readed from > client. > > Then, i know the size of rest of the packet till new one, i want my > callback executed when the size of packet + 2 (tail) bytes have been > readed > from the client. Then same steps again. (4 byte) > > OR is there any recommended way to do this in libuv? > > Thanks, > Burak > > -- > You received this message because you are subscribed to the Google Groups > "libuv" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/libuv. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "libuv" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/libuv. For more options, visit https://groups.google.com/d/optout.
