Go Down

Topic: Ethernet Sheild and GSM router (Read 3 times) previous topic - next topic


Oct 09, 2012, 03:53 pm Last Edit: Oct 09, 2012, 03:59 pm by SurferTim Reason: 1
Why don't you wait for the server to close the connection? That is the signal it is finished sending packets. If it is like the ethernet library, you should be able to use this. It should wait ten seconds for a packet before aborting the connection.
Code: [Select]
while(_client.connected()) {
 while(_client.available()) {
   // if a packet arrives, reset the attempts counter
   attempts = 0;
 // increment counter and wait 1ms

 // if the counter has reached the timeout value, close the connection
 if(attempts > 10000) _client.stop();
// close the connection on your end after the server closes the connection
// This would be the second stop if there is a timeout,
// but does not affect the ethernet shield.

My apology in advance for errors or typos.

edit: I had the wrong delay value. It is now corrected.


HI pylon, ive tried doing what you did, but unfortunatly it hasnt wroked as of yet. Where di you pluck the 14 from? (just trying to understand?)

SurferTim is that code a modification of the c++ library? (which is what im trying to do)



Look here. Is this the code you are using?
All those functions are available with that library also. This is pretty standard TCP stuff. The transport should be transparent.


Oct 09, 2012, 04:30 pm Last Edit: Oct 09, 2012, 04:32 pm by gibbon Reason: 1
Yes that is what im using, but its not working when used with a GSM router and we think this is becasue the GSM might be splitting up packets and the library therefore isnt interpreting the handshake correctly.



The code I posted above does not matter how many packets the response is sent in. It could be one packet with a thousand characters, or a thousand packets with one character. It waits for the server to close the connection. That is why the "while(client.connected())" loop.

Go Up