Advertisement

Hi all, a question about networking winsock size thing.

Started by July 25, 2004 05:09 PM
1 comment, last by NightMarez 20 years, 6 months ago
okay im sitting here and cannot figure this one out, i need a simple and clean method on getting size convertet from hex to a value.. lets say packet looks like this: [0A 00] [xx xx xx xx 8 byte data xx xx xx xx] k, we first i pop in a receive... recv(blablabla, 2, 0) receive the first 2 (wich is size 0A 00 = 10 bytes) thats size + size of TOTAL packet (dont ask) so, i wanna convert the 0A 00 to 10 (-2) to pop the next recv (the data) int size = 10-2; recv(data, size, 0) well you get the idea... a quick way to do that ?
unsigned short size; // assumig short is 2 bytes on your platform
recv((char*)&size.......);

recv(....,size-2);

? (given the byte format, it looks like your machine is little endian, a big endian machine would have to convert first...)
Advertisement
thanks, works like a charm :)

This topic is closed to new replies.

Advertisement