Firstly, you can’t connect to a “server” using a GPRS connection. The GPRS bearer connection is the data connection the the cellular network. You need another protocol to actually create the connection to the server. The most common options are:
TCP :create a TCP server on the server, and a TCP client on the device
UDP: A connectionless, un-guaranteed protocol that requires a UDP listener on the server side
If you want the connection to be permanently established, the best way is to periodically communicate with the server and make sure you get the correct response. If the communications fail, or if you receive any error events in your TCP handlers, you can shut down the connection and recreate it.
Thanks tomridl for answer , I forgot to mention that I am making TCP client connection to server over GPRS data.
For recreating connection to TCP server in case of conntion drop, is it fine if I place function startClient(); in WIP_CEV_PEER_CLOSE and IP_CEV_ERROR block?
see code below:
I think you should check the error type(ev->content.error.errnum) in WIP_CEV_ERROR case to decide creating the socket again. The error type may not be related with socket disconnection. In this case you dont need to create a new socket.
And you can handle WIP_CEV_DONE event also just in case of your application closes the socket somehow.
WIP_COPT_KEEPALIVE option will work for your case of keeping the connection alive. But you can also implement your own method so that you can have control on that methot.