Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more NetworkMonitor examples #1

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Add more NetworkMonitor examples #1

wants to merge 12 commits into from

Conversation

erlingrj
Copy link

This PR adds two new NetworkMonitor examples

@erlingrj
Copy link
Author

@edwardalee here is the work I have done on Network Monitoring. I am tagging you here so you can have a look and possibly give some feedback. In any case, we can discuss this on our next meeting. Perhaps it should live in a separate repo, and not in lf-demos, what do you think?

I had trouble running the Probe4.lf and Probe5.lf on my Macbook. They work as non-federated, but with federated they just terminate immediately, no logging output is printed. Very strange

Copy link
Contributor

@edwardalee edwardalee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very cool! Probe4.lf doesn't compile for me, however:

/Users/edwardlee/git/lf-demos/network-monitor/fed-gen/Probe4/src-gen/federate__m__0/./_simplehttpserver.h:6:10: fatal error: 'microhttpd.h' file not found
#include <microhttpd.h>
         ^~~~~~~~~~~~~~
1 error generated.

I think maybe it's missing a cmake-include?

Also, the HTTP server looks nice. I've been meaning to turn the reactors here into a Lingo package. This would also enable a web socket connection. Should we use those? I haven't compared to yours...

network-monitor/README.md Outdated Show resolved Hide resolved
@erlingrj
Copy link
Author

Looks very cool! Probe4.lf doesn't compile for me, however:

/Users/edwardlee/git/lf-demos/network-monitor/fed-gen/Probe4/src-gen/federate__m__0/./_simplehttpserver.h:6:10: fatal error: 'microhttpd.h' file not found
#include <microhttpd.h>
         ^~~~~~~~~~~~~~
1 error generated.

I think maybe it's missing a cmake-include?

Also, the HTTP server looks nice. I've been meaning to turn the reactors here into a Lingo package. This would also enable a web socket connection. Should we use those? I haven't compared to yours...

Did you install libmicrohttpd with brew install libmicrohttpd? On my MacBook it was installed to /usr/local and thus in HttpServer.cmake I update include directories and link directories correspondingly. You can check where it was installed with sudo find / -name "microhttpd.h"

@edwardalee
Copy link
Contributor

Did you install libmicrohttpd with brew install libmicrohttpd? On my MacBook it was installed to /usr/local and thus in HttpServer.cmake I update include directories and link directories correspondingly. You can check where it was installed with sudo find / -name "microhttpd.h"

Yes, I installed it. The .h file ends up here: /opt/homebrew/include/microhttpd.h. Maybe there is some cmake magic that will find this? Otherwise, I guess some environment variable needs to be set explicitly.

@erlingrj
Copy link
Author

Did you install libmicrohttpd with brew install libmicrohttpd? On my MacBook it was installed to /usr/local and thus in HttpServer.cmake I update include directories and link directories correspondingly. You can check where it was installed with sudo find / -name "microhttpd.h"

Yes, I installed it. The .h file ends up here: /opt/homebrew/include/microhttpd.h. Maybe there is some cmake magic that will find this? Otherwise, I guess some environment variable needs to be set explicitly.

Could you try once more. I tried adding /opt/homebrew to the path CMake searches for libraries.

@erlingrj
Copy link
Author

Also, the HTTP server looks nice. I've been meaning to turn the reactors here into a Lingo package. This would also enable a web socket connection. Should we use those? I haven't compared to yours...

I had a look at ServerUI.lf and it is more general. But I think it is wiser to build on a well-established library, e.g. libmicrohttpd. A quick inspection and it looks like there is a race condition. If the user requests e.g. /foo, the listening thread will schedule a physical action and then go back to accept(). If a new request is accepted, then this will overwrite browser_ui->client_socket, which is used by the reaction triggered by the response port.

Wouldnt it be easier to let a library handle the sockets and threads?

@erlingrj
Copy link
Author

Perhaps a compromise, where I implement the generality of your proposal (i.e. the base HTTP reactor outputs requests on its output port and responds with whatever it receives on its input port), but base it off libmicrohttpd?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants