Hi Rolf
httpclient has the some behaviour for me, it works then fails after a while
Today , I tried to UDP functions and lwip API functions
For UDP, I have to import "http://mbed.org/projects/cookbook/svn/EMAC/lwip/trunk/Core" .
But for API... I saw api.h and api_msg.h, but cpp can't be compiled
Here is a doc "http://www.sics.se/~adam/lwip/doc/lwip.pdf" where you can see on page 29
int main() {
struct netconn *conn;
struct netbuf *buf;
struct ip_addr addr;
char *data;
char text[] = "A static text";
int i;
/* create a new connection */
conn = netconn_new(NETCONN_UDP);
/* set up the IP address of the remote host */
addr.addr = htonl(0x0a000001);
/* connect the connection to the remote host */
netconn_connect(conn, &addr, 7000);
/* create a new netbuf */
buf = netbuf_new();
data = netbuf_alloc(buf, 10);
/* create some arbitrary data */
for (i = 0; i < 10; i++) {
data[i] = i;
}
/* send the arbitrary data */
netconn_send(conn, buf);
/* reference the text into the netbuf */
netbuf_ref(buf, text, sizeof(text));
/* send the text */
netconn_send(conn, buf);
/* deallocate connection and netbuf */
netconn_delete(conn);
netconn_delete(buf);
}
If you had a new core, can you check that
Regards
Hi Pierre,
I answer you here because it is not HTTPServer related. And this topic might fit better.
If you want to use UDP with the lwIP stack you have to import the Core, that’s right.
If you have a look around the in the lwIP library you will see that there is no API.h provided. Like Adam Dunkels said, in his description on pages 15-16, chapter 11, to use the application program interface (API) the system has to provide a multi thread environment. What mbed does not provide by itself. So I decided the easiest way to provide HTTP connectivity is to use the internal TCP API.
If you want to proceed in the same manner, you can use the functions provided by udp.h. The netbios example posted by Chris uses this API so it might be a good example.
By the way, what is your project about?
Cheers
Rolf
Question : I need to use the UDP protocol . Is it possible with the mbed?
There is an implementation of lwip for mbed, which some classes have been built on that use TCP/IP. However, there are no classes using UDP.
The short answer is yes, UDP is possible. If you want to build on lwip there is an example of the TCP/IP implementation as a guide :
http://mbed.org/projects/cookbook/wiki/EMAC/purehttpc
There are also some lwip examples of UDP in use :
http://cvs.savannah.gnu.org/viewvc/contrib/apps/netbios/?root=lwip