lr socket 接收消息编程

#include "lrs.h"




/*********************************************************************
 * Created by Mercury Interactive Windows Sockets Recorder
 *
 * Created on: Tue Oct 16 17:06:33
 *********************************************************************/
/*
#include "lrs.h"

int dint = 1;
char str[1024];
char dchar[];
char* test;
char* RemoteHost;
*/

/*
   测试接收字符

*/


char* RemoteHost;
char ff[1024];
char* recv_msg;

int res;

Action()
{

	RemoteHost = lr_eval_string("RemoteHost=192.168.47.129:6000");
    
   //创建socket
   lrs_create_socket("socket0", "TCP",RemoteHost , LrsLastArg);


   lrs_send("socket0","sbuf", LrsLastArg ); 


   lrs_receive("socket0", "rbuf", LrsLastArg);

   //保存数据的 要知道偏移量根据偏移量取数据
   lrs_save_param("socket0", "rbuf", "tt", 0, 1);
   lrs_save_param("socket0", "rbuf", "bb", 2, 3);

   //第二个参数设置成NULL 要确定知道字符大小
   //lrs_save_param("socket0", NULL, "tt",0,5);

   //recv_msg = lr_eval_string("tt");
   // lr_output_message("the message that i received is ====: %s", recv_msg);
   // 
   //  lr_output_message ("String: %s",lr_eval_string("<tt>")); 

  lr_output_message ("tt===: %s",lr_eval_string("<tt>")); 

  //字符判断
  res = strcmp(lr_eval_string("<tt>"),"t");

  lr_output_message ("res: %d",res); 


  if(res == 0){

    lr_output_message ("-------------------------------------------"); 

  }


  
   lr_output_message ("String: %s",lr_eval_string("<bb>")); 
   lr_output_message ("Shuzi: %d",atoi(lr_eval_string("t"))); 
  

   // lr_output_message("Parameter1 is  : %s", lr_eval_string("sbuf"));

   //关闭打开的socket;
   lrs_close_socket("socket0");






    return 0;
}

 

你可能感兴趣的:(socket)