htons function

alexchang
Posts: 52
Joined: Mon Apr 06, 2015 5:47 pm

htons function

Postby alexchang » Mon Apr 27, 2015 3:35 pm

When I implement websocket client, I need a function : htons(), I know this function is under netinet/in.h when we use linux base os, here we need to include the lwip library.

Since I use IoT sample project, lwip is included by default, the only thing I need to do is adding includes, then I try to include h files one by one, but I found I can't do it, because I need to include almost every lwip and system h files.

Just want to know which is the easiest way to use this function? Thanks!

alexchang
Posts: 52
Joined: Mon Apr 06, 2015 5:47 pm

Re: htons function

Postby alexchang » Mon Apr 27, 2015 3:41 pm

should be this :
#define htons(_n) ((uint16_t)((((_n) & 0xff) << 8) | (((_n) >> 8) & 0xff)))

Thanks!

Who is online

Users browsing this forum: No registered users and 148 guests