Listing 2. Receiving Short Messages

void main(void)
{
     read_cfgfile(variables);
     socket = initialize_socket(port);
     command(socket, "at+cnmi=1,2\r");
     while(1) {
         listen(socket);
         if (sms_received == TRUE)
              if (sms_contains_emailaddress == TRUE)
                      send(e-mail);
              else printf(sms_message)
     }
close(socket);
}