Connection Failures

What functions handle TCP/IP connection failures?

I´m using ed_lib for this matter and whenever I lose connection with the service provider, I would like to restablish the connection.

Best Regards,

Henrique

You have to watch for events in event handlers You subscribed in

ed_DialupConnectionStart and
ed_SocketTCPStart, if You use TCP socket

Be prepared to handle all events such as: ED_ERR_GPRS_SESSION_LOST, ED_OK_TCP_CLOSED, ED_ERR_DISTANT_TCP_CLOSED_BY_PEER, ED_ERR_DISTANT_NO_RESP etc.

Action depends on event detected and Your application may need different response to different error events on different situation/internal state.

Hi, thanks for the previous help.

Here´s what I got:

I have 2 servers with different IPs. It may happen that one of the server be down. So I would like to try a connection with the other one.

When the event before happens, I get the following answer:
ED_ERR_DISTANT_NO_RESP

I´m already attached to the service provider and I got a valid IP.

What function should I use to restablish the connection to a working server?

Here´s what I´m trying to do:

case ED_ERR_DISTANT_OPEN: 

			TRACE((1, "ED_ERR_DISTANT_OPEN"));

			FreeIP = FALSE;

			exchangeIP();

			th=(adl_tmr_t *)adl_tmrSubscribe(FALSE, timeout_period, ADL_TMR_TYPE_100MS, (adl_tmrHandler_t) Timer_FreeIP);


			break;



void Timer_FreeIP(u8 Id)
{
	s8  sReturn = ERROR;
	s8 ipsubReturn;
	u16 timeout_period=30;
	adl_tmr_t *th;


	TRACE((1, "**Timer FreeIP**"));

	ipsubReturn = ed_SocketLTCPStop (ED_ID_TCPSOCKET_1,(ed_ResponseCbk_f)tcp_Stop_pfResponseCbk);
	ed_SocketTCPStart (ED_ID_TCPSOCKET_1, 0,(ed_ResponseCbk_f)tcp_pfResponseCbk, (ed_DataHandler_f)tcp_pfDataHnd, (ed_DataRequest_f)tcp_pfDataRequest);


	if(FreeIP==FALSE)
	{
		TRACE((1, "**FreeIP: Problems, trying again...**"));
		th=(adl_tmr_t *)adl_tmrSubscribe(FALSE, timeout_period, ADL_TMR_TYPE_100MS, (adl_tmrHandler_t) Timer_FreeIP);			
	}

}

But this way I never get re-connected again…
As I never get reconnected again, the Timer subscribed is called everytime trying to do something that it´s supposed to do.

What should I do?

Best Regards,
Henrique

Hi Henrique,

what does the program do? does it connect to a server or is it the server?? If it is not the server, you should not use the function ed_SocketLTCPStop() -this would stop a listening connection- which you would not have on the client side!

Best Regards,
Jan

Do you suggest any proceedings to force connection failures?

Like: removing the atenna, shutting the server…

Best Regards,

Henrique