Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 6 months ago.
understanding HTTPServer/EthernetNetIf
This is the code i get when i strip off all the non relevant information for the server example program:
#include "EthernetNetIf.h" #include "HTTPServer.h" #include "RPCFunction.h" #include "RPCVariable.h" EthernetNetIf eth; HTTPServer svr; EthernetErr ethErr = eth.setup(75000); svr.addHandler<RPCHandler>("/rpc"); svr.bind(80); main{ Net::poll(); }
I try to understand what is hapening and which does what. I make my own assumptions, please correct me if im wrong. thank you. i try to learn
#include "EthernetNetIf.h"
This library is responsable for the accepting and sending of data??
#include "HTTPServer.h"
this library is responsable for creating the socket and attaching him to a port nr??
EthernetNetIf eth; //comes from the EthernetNetIf library
This makes a connection with the router to get a IP through the DHCP server. But i have the same assumtion for EthernetErr ethErr = eth.setup();???
HTTPServer svr; //comes from library HTTPServer.h
There is a socket created. It makes the socket a listening socket who is waiting on the initiative of a client.
EthernetErr ethErr = eth.setup(); comes from which library?
This makes a connection with the router to get a IP through the DHCP server. And gives back a value that says if this is succeeded or not. whats difference with EthernetNetIf eth; ??
Svr.bind(80); //comes from library HTTPServer.h
The socket which was created in HTTPServer svr is now bind to port nr 80
svr.addHandler<RPCHandler>("/rpc"); //comes from library HTTPServer.h
there is a handler added to the socketAPI, so now this socket understands what we want to do if we send him some RPChandlers (off course with the RPC librarys included)
Net::poll(); comes from which library?
The server checks in his receive buffer if there is something waiting there. This also executes the code he finds there(if he understands it)???? I assume this because this is the only call going on in the main, so this must do everything after the socket is created?
what I’m still missing is:
where is the socket accepting incoming connections?
Where is the communicating with the remote host with send, recv, write and read functions?
Thnx, this would help me a lot understanding whats happening