Example program with HTTPServer and sensor data streaming over TCPSockets, using Donatien Garnier's Net APIs and services code on top of LWIP. Files StreamServer.h and .cpp encapsulate streaming over TCPSockets. Broadcast is done by sendToAll(), and all incoming data is echoed back to the client. Echo code can be replaced with some remote control of the streaming interface. See main() that shows how to periodically send some data to all subscribed clients. To subscribe, a client should open a socket at <mbed_ip> port 123. I used few lines in TCL code to set up a quick sink for the data. HTTP files are served on port 80 concurrently to the streaming.
def.c File Reference
Common functions used throughout the stack. More...
Go to the source code of this file.
Functions | |
u16_t | htons (u16_t n) |
These are reference implementations of the byte swapping functions. | |
u16_t | ntohs (u16_t n) |
Convert an u16_t from network- to host byte order. | |
u32_t | htonl (u32_t n) |
Convert an u32_t from host- to network byte order. | |
u32_t | ntohl (u32_t n) |
Convert an u32_t from network- to host byte order. |
Detailed Description
Common functions used throughout the stack.
Definition in file def.c.
Function Documentation
u32_t htonl | ( | u32_t | n ) |
u16_t htons | ( | u16_t | n ) |
These are reference implementations of the byte swapping functions.
Again with the aim of being simple, correct and fully portable. Byte swapping is the second thing you would want to optimize. You will need to port it to your architecture and in your cc.h:
define LWIP_PLATFORM_BYTESWAP 1 define LWIP_PLATFORM_HTONS(x) <your_htons> define LWIP_PLATFORM_HTONL(x) <your_htonl>
Note ntohs() and ntohl() are merely references to the htonx counterparts. Convert an u16_t from host- to network byte order.
- Parameters:
-
n u16_t in host byte order
- Returns:
- n in network byte order
u32_t ntohl | ( | u32_t | n ) |
Generated on Tue Jul 12 2022 21:10:26 by 1.7.2