Trying to connect gprs and trying to send data using TCP but facing problem


Hi ,

I want to connect to gprs and establish socket connection with server and then send and receive data.
For this, I have 1st established connection using commands as below
cm radio
cm data
(if apn not set) cm data apn ‘apn name’
(if not connected ) cm data connect &

here it is showing connected using interface 'rmnet0’
In project, I have used again data connection functions and then added socket code for connection to server and send data.

I have used following functions:

after these three connection functions, I am starting socket code.
while running application, it takes much time to create socket and execution of code.

My question is that,
my code flow is correct or not and if I doing wrong then what is correct flow to connect and send and receive data ?


I think the code flow is correct. Just to be clear, you need to wait for the connection state change handler to be called after calling le_data_Request and you should verify that the isConnected parameter is true. At that time the connection is ready for you to create the socket.


I am connecting to gprs using terminal command (cm data connect &)first and then running my application. In this case only I am able to send and receive data , in other case socket connection does not get connect to server.
I want to do everything through my code only. that is, gprs connection.
How can I do this? or
How can I give Terminal commands to mangOH board using my code?