Problem in writing code which performs GPRS support action.

I am trying to send data through GPRS via SIM300 modem. The logic of my program should be.
1) it should send the data till it receives "dieman" from the server.
2) the modem is such that after every command there is a reply.
3) all the communication takes place serially.

Firstly the GPRS commands as tried in hyperterminal

AT
OK
AT+CGATT=1
OK
AT+CGDCONT=1,"IP","airtelgprs.com"
OK
AT+CSTT="airtelgprs.com","",""
OK
AT+CIICR
OK
AT+CIFSR
212.22.22.22                  //EG OF AN IP ADDRESS
AT+CIPSTART="TCP",""80"">http://www.google.com","80"
OK

CONNECT OK
AT+CIPSEND
>THIS IS THE DATA I WANNA SEND             // YOU CAN SEND THE DATA VIA GPRS NOW
 [CTRL+Z]
SEND OK

this is what i want to implement in C in 8052. here OK are the response from the modem.

now i implemented the C version but my code is very inefficient. I could have ignored the response from the modem by simply inserting delays but i want my code such that if the reply from the modem is not "OK" it should transmit the command again.

More questions in this forum