Problems with the ftp


I have a problem with the ftp
I am trying to put some data that is in a buffer to a ftp server.
The algorithm is something like this
Every 200 seconds try to put data to ftp server.

I start the transmission and mark the buffer as busy. If I get back some error event I try to retransmit the buffer. If the trasmission was succesful I mark the buffer as free and a new transmission can begin.
If I remove the GSM antenna so the signal is lost, when the signal came back I got this problem:

The thing is that after about 10 minutes (and this is repeting after 10 minutes) i get a socket error (it seems like an error that you receive when you try to connect to a socket that is already in use)
So could anybody help me out with this?
I guess my problem is what to do with the data i want to put to ftp, when to resend it if i can’t put it to ftp the first time (because the gsm signal is down)


What about monitoring the state of the GPRS link through AT commands? Whenever you detect a loss of carrier for longer than, say, 30sec:

  • cancel your FTP connection (wip_close control & transfer sessions)

  • remember to redo it when the link is back up

  • optionally, use the FTP resume features to avoid restarting from scratch, if your server supports it.


eg, +CREG and/or +CGREG unsolicited responses :question:


ok thanks guys this is a pretty good idea
the problem is that if there is signal but it is insufficent (csq return 5 or something like this ) i still can’t put data to ftp, so i gues monitoring the signal with csq is a better solution
Do you have some other suggestions?


I don’t think so - and you just said yourself that monitoring CSQ is not a good indication!

CSQ is not a good indicator - use +CREG and/or +CGREG, as these give a positive indication of whether you do or do not have service!

Note that you can get a “good” CSQ indication when your unit is registered to another network in “Emergency Calls Only” mode - but you won’t have any other service!