Hi All!
Im kinda of new to this networking stack. I'm trying to learn it as much as I can but its inevitable to take this opportunity to ask just few questions:
In my project, Im' trying to understand the program HTTPServerExample. I'm paying attention to files HTTPServer.h/cpp , HTTPRequestDispatcher.h/cpp, HTTPRequestHandler.h/cpp. I guess that my first question has to do with a "field" called "setOnEvent" of the TCPSocket that is constantly changed whenever I am in HTTPServer.cpp, or HTTPRequestDispatcher.cpp or HTTPRequestHandler. And the reason why I mentioned this is because I'm trying to figure out, in the highest level of abstraction, like in HTTP service, what happens if there is new data in that socket. I'm kinda of aware that either netservices.h or net.h has the function that needs to be polled ( Net::poll() ) in order to detect new activity on the network (right?). So who is the first responsible to handle data when there is new data on the socket? I know that at least in these 3 files there is a function "onTCPSocketEvent", does this has something to do with my question? If not, what is the purpose of this function that gets defined in each file?
Another question is what exactly is a handler? I kind of have an idea but I need more in order to fully understand it. After "assigning it" in the main.cpp (of the mentioned program), in HTTPRequestDispatcher.cpp, we look for a handler (which by the way, I don't know much about C plus plus and I'm having a hard time to understand how in this part of the code works, with iteration it?) in m_pSvr->m_lpHandler. Once we found it (let's say we did) we create:
HTTPRequestHandler* pHdlr = (*it).second((*it).first.c_str(), path.c_str() + root_len, m_pTCPSocket);
(by the way, we are creating a pointer pHdlr and to what are we making it equal? and why is there a coma(,)?
and the invoke the function, lets say doGet().
(another spin off: we search for handlers in HTTPRequestDispatche.cpp but this is inside the function dispatchRequest() that is called in the onTCPSocketEvent(), who could call this function (kind of the same question as earlier)?
I hope you can help me. I know that for some (if not all hehe) this is very easy. It's just that I'm trying to really understand how it works.
I really thank you for your time!
I have just released the new networking stack stack. I have also setup a page here in the wiki that will list the changes for each release:
http://mbed.org/cookbook/Networking-Stack-Releases
If you experience any bug, want to contribute some code, improve something in the stack or have features requests this is the right thread to do so.
Hope that this will be useful!
Donatien