BlakeFoster / Arduino-Ping

ICMP ping library for the Arduino
58 stars 44 forks source link

Ping from a webserver #12

Open FrankC2000 opened 7 years ago

FrankC2000 commented 7 years ago

Nice work here! Thanks!

My purpose is to build a little webserver in a box. I will put a led outside to indicate the whether network is on (connected). So I ping the gateway eache 5 secs to set the led.

The problem is, as soon as the server starts to receive HTTP requests, it doesn't ping the gateway anymore, I mean does not receive SUCCESS status. Could be a socket issue?

Any thoughts? Thanks in advance.

BTW, a changed pingSocket from 0 to 3 but it didn't work.

Keep up the good work!

BlakeFoster commented 7 years ago

Yes, it's probably a socket conflict. I'm not sure what libraries you're using for the HTTP server, but I would look there to see how it's picking sockets. It's probably paving over the raw socket used for ICMP. -Blake

FrankC2000 wrote:

Nice work here! Thanks!

My purpose is to build a little webserver in a box. I will put a led outside to indicate the whether network is on (connected). So I ping the gateway eache 5 secs to set the led.

The problem is, as soon as the server starts to receive HTTP requests, it doesn't ping the gateway anymore, I mean does not receive SUCCESS status. Could be a socket issue?

Any thoughts? Thanks in advance.

BTW, a changed pingSocket from 0 to 3 but it didn't work.

Keep up the good work!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/BlakeFoster/Arduino-Ping/issues/12, or mute the thread https://github.com/notifications/unsubscribe-auth/AD-QzVSTcx8qhlg0aDZ_NyZ_wcdbcCmdks5sSziLgaJpZM4OnXEk.

FrankC2000 commented 7 years ago

Thank you for your quick reply! Almost a ping ;)

I extended the Ethernet/Webserver example that comes with the IDE. The library is Ethernet.h. I have no idea what to change there.

BlakeFoster commented 7 years ago

If I remember correctly, the Ethernet library automatically picks a socket that is not in use. I would suggest initializing the ICMP socket before doing anything else with the Ethernet, if you're not already. In theory, the Ethernet library should detect that you're using that socket and skip it (probably--I don't actually remember how it detects whether a socket is being used). There are only 4 sockets, so your chances of getting a conflict if you don't take steps to avoid one are high. -Blake

FrankC2000 wrote:

Thank you for your quick reply! Almost a ping ;)

I extended the Ethernet/Webserver example that comes with the IDE. The library is Ethernet.h. I have no idea what to change there.

  • Frank

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/BlakeFoster/Arduino-Ping/issues/12#issuecomment-318898709, or mute the thread https://github.com/notifications/unsubscribe-auth/AD-QzfqyqiQftEUJlJr71lWY2r91eDEkks5sTHc-gaJpZM4OnXEk.

FrankC2000 commented 7 years ago

What do you mean by initializing the ICMP socket? The very first call to the ICMPEchoReply.ping method?

I call Ethernet.begin before the first call to the ICMPEchoReply.ping.