The usual apologies for perhaps posting something that has already been dealt with elsewhere!
I am just learning the Arduino Ethernet stuff (although I have been doing Arduino stuff for a few months) and I am just trying to build a simple POP3 email checker – i.e. – log into my POP3 server and tell me if I have any emails and how many I have and indicate this physically somehow with lights or on a serial display.
I am using a brand new Arduino Duemilanove and an Arduino Ethernet shield and Arduino 0017 and building on the Client test code found on the Arduino Ethernet Library reference.
What I have found when I started running this code was that it would go through once, but when I tried to get it to loop continuously it would hang up. Eventually, I set up a simple PHP server program on my PC using some code off of the PHP site and tested with it to see what was going on. What PHP tells me is that on the 2nd loop, it gives me:
PHP Warning: socket_read(): unable to read from socket [10054]: An existing connection was forcibly closed by the remote host.
So, I hooked it up to Wireshark and I can see that the Arduino is definitely sending a reset packet that kills the connection:
I have tried various suggestions for changes to the Client.h and client.cpp files, but to no avail.
Anyway, this is annoying since it really seems like either there is something wrong with the sample code from Arduino or something wrong with the Ethernet library! Lots of people seem to be discussing it on the boards, but I can't get through to a definite fix. Any suggestions anyone?
Yes, I think they did that on purpose so that it only grabs the info once but gives you an idea on how to do it. Anything in setup() will only run once, and the loop(), well it loops. You'll need to decide how you want to trigger your connection be it interval based or from some other input.
You'll need to connect again before it will pull data, this is what is currently in the setup() area. If you post your code attempt, we can help you out more.
Excellent, this works fine when I try it with the Google IP address given in the original Arduino Ethernet Client example (64.233.187.99), but won't work with my test PHP socket application, so that shows there is something wrong with my test socket app - perhaps timing or something! Now I can adapt it to the POP3 example I wanted to try originally then fool around with the PHP server later.
Forgive my ignorance, but why would this work with the code in functions rather than the main loop - apart from the fact that it is neater?
Also, the compiler warned me that "byte ip[] = { 192.168.0.172 };" needs to be byte ip[] = { 192, 168, 0, 172 };! Watch out for coding & beers! ;D
Again, thanks very much for the help! This really should be the Ethernet client demo code example!
Greetings! I'm trying out your code and have modified it to work with a BlinkM instead of a regular LED however, I am unable to connect. I suspect it might be due to the fact that I'm attempting to login to gmail's pop server, which requires SSL auth. Any ideas why I'm getting "connection failed"?
BTW - Great idea using the BlinkM! I was thinking about using a servo or something to create like a guage of my email, but I haven't gotten around to trying that yet. You can read more about my complete project on my blog: