Chinaunix首页 | 论坛 | 博客
  • 博客访问: 670734
  • 博文数量: 53
  • 博客积分: 830
  • 博客等级: 准尉
  • 技术积分: 1089
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-31 18:23
文章存档

2019年(1)

2018年(1)

2016年(1)

2015年(1)

2014年(12)

2013年(4)

2012年(33)

分类: 系统运维

2012-06-18 11:41:46

//  部分动态库写省略 
/* -------------------------------------------------------------------------------
    Script Title       :
    Script Description : dengdagui             
    Recorder Version   : 8859
   ------------------------------------------------------------------------------- */
   char *sRecvBuff;
   char *ActualBuffer;
   int sRecvLen;
   int NumberOfBytes;
   int creat_socket=1;
   char * ip = "62.148.78.139";

   int port = 20000;
   int socket;


vuser_init()
{

    lrs_startup(257);



     lr_load_dll("msvcp100.dll");
     lr_load_dll("msvcr100.dll");
     lr_load_dll("TestDll.dll");

     //112.84.189.112
     //61.147.75.112

    creat_socket=lrs_create_socket("socket0", "TCP", "LocalHost=0", "RemoteHost=113.94.199.129:20000", LrsLastArg);

    if(socket==creat_socket){

        lr_message("ok");
        }else{

           lr_message("not ok");

        }
 

   //     lrs_receive("socket1", "buf0", LrsLastArg);

    /*
    lrs_save_param("socket0", NULL, "param1", 0, -1);//可以将buf2接收到的全部信息保存到param1中,-1表示全部接收。
    lr_message("param1: %s", lr_eval_string(""));
    */

//----------------------------------------ok----------------------------
     lrs_send("socket0", "buf0", LrsLastArg);
     lrs_receive_ex("socket0", "buf1","NumberOfBytesToRecv=2", LrsLastArg);

    lrs_get_last_received_buffer("socket0",&sRecvBuff,&sRecvLen);

    lrs_save_param_ex("socket0","user",sRecvBuff,0,sRecvLen,"ascii","RecvBuf");

    lrs_free_buffer("sRecvBuff");
    lrs_free_buffer("socket0");

    lr_output_message("接收到的报文长度为:【%d】,\n报文内容为【%s】",sRecvLen,lr_eval_string(""));


    
//----------------------------------------握手----------------------------
    // 发送二进制二进制并打印大小和内容

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

     lrs_set_receive_option(EndMarker, EndMarker_None );
   //  lrs_set_receive_option(EndMarker, StringTerminator , "\r\n");

    lrs_receive_ex("socket0", "buf3","NumberOfBytesToRecv=10322", LrsLastArg);
    lrs_get_last_received_buffer("socket0",&sRecvBuff,&sRecvLen);

    lrs_save_param_ex("socket0","user",sRecvBuff,0,sRecvLen,"ascii","RecvBuf");

    lrs_free_buffer("sRecvBuff");
    lrs_free_buffer("socket0");

    lr_output_message("接收到的报文长度为:【%d】,\n报文内容为【%s】",sRecvLen,lr_eval_string(""));

         lr_message("握手结束!!");


    return 0;
}
================================================================

 // int rc;
 // int check_len;
 //
 // lrs_receive_ex("socket0", "buf5","NumberOfBytesToRecv=120",LrsLastArg);

Action()
{
 
//-----------------------------查询庄园信息1--------------------------

//    lrs_save_param_ex("socket0","user",sRecvBuff,0,sRecvLen,"ascii","RecvBuf");
   
    lr_start_transaction("查询庄园信息1");


       lrs_send("socket0", "buf4", LrsLastArg);
     lrs_set_receive_option(EndMarker, EndMarker_None );

    lrs_receive_ex("socket0", "buf5","NumberOfBytesToRecv=120",LrsLastArg);


    lrs_get_last_received_buffer("socket0",&sRecvBuff,&sRecvLen);

    lrs_save_param_ex("socket0","user",sRecvBuff,0,sRecvLen,"ascii","RecvBuf");

    lrs_free_buffer("sRecvBuff");
    lrs_free_buffer("socket0");
   



    lr_output_message("接收到的报文长度为:【%d】,\n报文内容为【%s】",sRecvLen,lr_eval_string(""));
               lr_message("查询庄园信息1");

  // 检查点分别对接受长度和部分内容进行检查.


    if (sRecvLen==120)

    {
    lr_end_transaction("查询庄园信息1", LR_PASS);
    lrs_free_buffer(sRecvBuff);

    }
    else{
   
    lr_end_transaction("查询庄园信息1", LR_FAIL);

    lr_error_message("接收到的报文长度为:【%d】,\n报文内容为【%s】",sRecvLen,lr_eval_string(""));

    lrs_free_buffer(sRecvBuff);

    }

//-----------------------------查询庄园信息2--------------------------
              
    lr_start_transaction("查询庄园信息2");

     lrs_send("socket0", "buf6", LrsLastArg);
     lrs_set_receive_option(EndMarker, EndMarker_None );

    lrs_receive_ex("socket0", "buf7","NumberOfBytesToRecv=120",LrsLastArg);


    lrs_get_last_received_buffer("socket0",&sRecvBuff,&sRecvLen);

    lrs_save_param_ex("socket0","user",sRecvBuff,0,sRecvLen,"ascii","RecvBuf");

    lrs_free_buffer("sRecvBuff");
    lrs_free_buffer("socket0");

    lr_output_message("接收到的报文长度为:【%d】,\n报文内容为【%s】",sRecvLen,lr_eval_string(""));
   
               lr_message("查询庄园信息2");


  // 检查点分别对接受长度和部分内容进行检查.


    if (sRecvLen==120)

    {
    lr_end_transaction("查询庄园信息2", LR_PASS);
    lrs_free_buffer(sRecvBuff);

    }
    else{
   
    lr_end_transaction("查询庄园信息2", LR_FAIL);

    lr_error_message("接收到的报文长度为:【%d】,\n报文内容为【%s】",sRecvLen,lr_eval_string(""));

    lrs_free_buffer(sRecvBuff);

    }

//-----------------------------查询庄园信息3--------------------------
              
    lr_start_transaction("查询庄园信息3");


     lrs_send("socket0", "buf8", LrsLastArg);
     lrs_set_receive_option(EndMarker, EndMarker_None );

    lrs_receive_ex("socket0", "buf9", "NumberOfBytesToRecv=120",LrsLastArg);


    lrs_get_last_received_buffer("socket0",&sRecvBuff,&sRecvLen);

    lrs_save_param_ex("socket0","user",sRecvBuff,0,sRecvLen,"ascii","RecvBuf");

    lrs_free_buffer("sRecvBuff");
    lrs_free_buffer("socket0");

    lr_output_message("接收到的报文长度为:【%d】,\n报文内容为【%s】",sRecvLen,lr_eval_string(""));
   

               lr_message("查询庄园信息3");

  // 检查点分别对接受长度和部分内容进行检查.

   
    if (sRecvLen==120)

    {
    lr_end_transaction("查询庄园信息3", LR_PASS);
    lrs_free_buffer(sRecvBuff);

    }
    else{
   
    lr_end_transaction("查询庄园信息3", LR_FAIL);

    lr_error_message("接收到的报文长度为:【%d】,\n报文内容为【%s】",sRecvLen,lr_eval_string(""));

    lrs_free_buffer(sRecvBuff);

    }


//-----------------------------查询庄园信息4--------------------------
              
    lr_start_transaction("查询庄园信息4");


     lrs_send("socket0", "buf10", LrsLastArg);
     lrs_set_receive_option(EndMarker, EndMarker_None );

    lrs_receive_ex("socket0", "buf11","NumberOfBytesToRecv=107", LrsLastArg);


    lrs_get_last_received_buffer("socket0",&sRecvBuff,&sRecvLen);

    lrs_save_param_ex("socket0","user",sRecvBuff,0,sRecvLen,"ascii","RecvBuf");

    lrs_free_buffer("sRecvBuff");
    lrs_free_buffer("socket0");

    lr_output_message("接收到的报文长度为:【%d】,\n报文内容为【%s】",sRecvLen,lr_eval_string(""));
   
               lr_message("查询庄园信息4");

  // 检查点分别对接受长度和部分内容进行检查.

 
    if (sRecvLen==107)

    {
    lr_end_transaction("查询庄园信息4", LR_PASS);
    lrs_free_buffer(sRecvBuff);

    }
    else{
   
    lr_end_transaction("查询庄园信息4", LR_FAIL);

    lr_error_message("接收到的报文长度为:【%d】,\n报文内容为【%s】",sRecvLen,lr_eval_string(""));

    lrs_free_buffer(sRecvBuff);

    }

//-----------------------------查询庄园信息5--------------------------
              
    lr_start_transaction("查询庄园信息5");


     lrs_send("socket0", "buf12", LrsLastArg);
     lrs_set_receive_option(EndMarker, EndMarker_None );

    lrs_receive_ex("socket0", "buf13", "NumberOfBytesToRecv=107",LrsLastArg);


    lrs_get_last_received_buffer("socket0",&sRecvBuff,&sRecvLen);

    lrs_save_param_ex("socket0","user",sRecvBuff,0,sRecvLen,"ascii","RecvBuf");

    lrs_free_buffer("sRecvBuff");
    lrs_free_buffer("socket0");

    lr_output_message("接收到的报文长度为:【%d】,\n报文内容为【%s】",sRecvLen,lr_eval_string(""));
   

               lr_message("查询庄园信息5");

  // 检查点分别对接受长度和部分内容进行检查.


    if (sRecvLen==107)

    {
    lr_end_transaction("查询庄园信息5", LR_PASS);
    lrs_free_buffer(sRecvBuff);

    }
    else{
   
    lr_end_transaction("查询庄园信息5", LR_FAIL);

    lr_error_message("接收到的报文长度为:【%d】,\n报文内容为【%s】",sRecvLen,lr_eval_string(""));

    lrs_free_buffer(sRecvBuff);

    }

//-----------------------------查询庄园信息6--------------------------
              
    lr_start_transaction("查询庄园信息6");


     lrs_send("socket0", "buf14", LrsLastArg);
     lrs_set_receive_option(EndMarker, EndMarker_None );

    lrs_receive_ex("socket0", "buf15","NumberOfBytesToRecv=107",LrsLastArg);


    lrs_get_last_received_buffer("socket0",&sRecvBuff,&sRecvLen);

    lrs_save_param_ex("socket0","user",sRecvBuff,0,sRecvLen,"ascii","RecvBuf");

    lrs_free_buffer("sRecvBuff");
    lrs_free_buffer("socket0");

    lr_output_message("接收到的报文长度为:【%d】,\n报文内容为【%s】",sRecvLen,lr_eval_string(""));

    lr_message("查询庄园信息6");


  // 检查点分别对接受长度和部分内容进行检查.
   
    if (sRecvLen==107)

    {
    lr_end_transaction("查询庄园信息6", LR_PASS);
    lrs_free_buffer(sRecvBuff);

    }
    else{
   
    lr_end_transaction("查询庄园信息6", LR_FAIL);

    lr_error_message("接收到的报文长度为:【%d】,\n报文内容为【%s】",sRecvLen,lr_eval_string(""));

    lrs_free_buffer(sRecvBuff);

    }

   
    return 0;
}
===============================================================
vuser_end()
{
    lrs_close_socket("socket0");
    lrs_cleanup();
    return 0;
}

================================================================
;WSRData 2 1

send  buf0 352
    "test:connect."
   

recv  buf1 291
    "okaaaa"
   

send  buf2 603     //握手 (获取当前地图立标及地图人数)
      "\x00\x00\x00\x18\x0a\x0b\x01\x03\x76\x09\x01\x01\x03\x65\x05\x41\xd2\x90\x5a\x9c\x00\x00\x00\x03\x74\x04\x02\x01"
   

recv  buf3 292   
    "aaa"
   

send  buf4 604    //查询庄园信息1
                                                            0                                        
    "\x00\x00\x00\x28\x0a\x0b\x01\x03\x76\x09\x03\x01\x06\x1d\x74\x6f\x77\x6e\x2f\x30\x30\x31\x31\x30\x30\x30\x30\x30\x03\x65\x05\x41\xc4\x44\x4e\x3d\x00\x00\x00\x03\x74\x04\x02\x01"

recv  buf5 604
    "aaaa"

//---------------------------------------------
send  buf6 14913   //查询庄园信息2                             
                   //   0                                                  0
    "\x00\x00\x00\x28\x0a\x0b\x01\x03\x76\x09\x03\x01\x06\x1d\x74\x6f\x77\x6e\x2f\x30\x30\x31\x31\x30\x30\x30\x30\x31\x03\x65\x05\x41\xc4\x44\x4e\x3d\x00\x00\x00\x03\x74\x04\x02\x01"
   
recv  buf7 604
    "aaaa"


//---------------------------------------------
send  buf8 14913   //查询庄园信息3                                0
    "\x00\x00\x00\x28\x0a\x0b\x01\x03\x76\x09\x03\x01\x06\x1d\x74\x6f\x77\x6e\x2f\x30\x30\x31\x31\x30\x30\x30\x30\x32\x03\x65\x05\x41\xc4\x44\x4e\x3d\x00\x00\x00\x03\x74\x04\x02\x01"
   
recv  buf9 604
    "aaaa"


//---------------------------------------------
send  buf10 14913   //查询庄园信息4                                 0
    "\x00\x00\x00\x28\x0a\x0b\x01\x03\x76\x09\x03\x01\x06\x1d\x74\x6f\x77\x6e\x2f\x30\x30\x31\x31\x30\x30\x30\x30\x33\x03\x65\x05\x41\xc4\x44\x4e\x3d\x00\x00\x00\x03\x74\x04\x02\x01"
   
recv  buf11 604
    "aaaa"

//---------------------------------------------
send  buf12 14913   //查询庄园信息5                                 0
    "\x00\x00\x00\x28\x0a\x0b\x01\x03\x76\x09\x03\x01\x06\x1d\x74\x6f\x77\x6e\x2f\x30\x30\x31\x31\x30\x30\x30\x30\x34\x03\x65\x05\x41\xc4\x44\x4e\x3d\x00\x00\x00\x03\x74\x04\x02\x01"
   
recv  buf13 604
    "aaaa"

//---------------------------------------------
send  buf14 14913   //查询庄园信息6                                 0
    "\x00\x00\x00\x28\x0a\x0b\x01\x03\x76\x09\x03\x01\x06\x1d\x74\x6f\x77\x6e\x2f\x30\x30\x31\x31\x30\x30\x30\x30\x35\x03\x65\x05\x41\xc4\x44\x4e\x3d\x00\x00\x00\x03\x74\x04\x02\x01"
   
recv  buf15 604
    "aaaa"

-1


阅读(2414) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~