My application upload contents on FTP server using ftplib which is written in C. The issue is during upload if the WLAN connection is lost (router restarted or the device is out from coverage) the connection disconnected but it failed to reconnect if device bring back into WLAN coverage area.
On debugging it's found that setsockopt function return -1
int sControl = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
int on = 1;
if (setsockopt(sControl,SOL_SOCKET,SO_REUSEADDR, SETSOCKOPT_OPTVAL_TYPE &on, sizeof(on)) != -1)
connect(sControl, (struct sockaddr *)&sin, sizeof(sin));
Any idea what makes this fail and how to fix it?
If I try to connect without calling setsockopt, the connect call also get failed. What options should I set in setsockopt?