title: GPRS Modem based data communication for Embedded Remote Client and Server
body: <p>For SAGEM HiLo GPRS based data communication, it has TCP/IP stack and there are two ways to get connected:</p>
  
  <p>(1) Using basic GPRS commands and then ppp dialing to brings the modem to public network/Internet like</p>
  
  <pre><code>AT+CGDCONT=1,"IP","APN","0.0.0.0",0,0
  OK
  atd*99***1#
  CONNECT
  </code></pre>
  
  <p>(2) Using GPRS attach and then using TCP socket commands such as</p>
  
  <pre><code>at&amp;k3
  OK
  
  AT+KCNXCFG=0,"GPRS","APN","log","pass
  word",”0.0.0.0”,”0.0.0.0”,”0.0.0.0”
  OK
  
  AT+KCNXTIMER=0,60,2,70
  OK
  
  AT+KCNXPROFILE=0
  OK
  
  AT+CGATT=1
  OK
  
  at+ktcpcfg=0,0,"www.domain.com",PortNo
  +KTCPCFG: 1
  OK
  
  AT+KTCPCNX=1
  OK
  
  AT+KTCPSND=1,18
  CONNECT
  …Data send…
  OK
  
  +KTCP_DATA: 1,1380
  AT+KTCPRCV=1,10000
  CONNECT
  </code></pre>
  
  <p>For Remote Client to connect with static IP server using TCP with a port number, I find may example that use basic GPRS commands not using any TCP/IP stack commands.</p>
  
  <p>What difference it makes in the two methods? I understand the first method is typically used for Internet browsing using a PC, and when should it not be like step 1, then followed by step 2.</p>
  
  <p>Some time I observed a problem that when GPRS modem assigns the connection IP starting with 117 then it works fine and when the assigned IP starts from 110 it connects with server and disconnects immediately. What could have the difference in the two cases and how to handle such situations? The location of GPRS modem is same in both cases, and mostly we get working IP if we start after a very long time and in case if Modem or connection is restarted, then IP assigned does not work.</p>