loadrunner winsocket 编程实例
针对公司平台的一个winsocket代码,期间遇到了打印字符串出错,100054错误,前一种主要是通过lr_eval_string()转换得出值,后一个主要是通过加一个lrs_close_socket();解决
char *ActualBuffer;
int NumberOfBytes;
char * position;
char * str;
char * search_str;
//lrs_set_connect_timeout(100,0);
lrs_create_socket("socket0", "TCP", "LocalHost=0", "RemoteHost=", LrsLastArg);
//lrs_set_connect_timeout(50,0);
lrs_send("socket0", "bufTest", LrsLastArg);
lrs_receive("socket0", "bufRecv", LrsLastArg);
lrs_get_last_received_buffer("socket0", &ActualBuffer, &NumberOfBytes);
lrs_save_param_ex("socket0", "user", ActualBuffer, 0, 500, "ascii", "new_parameter");
//lr_output_message("new_parameter = \"%s\"\n", lr_eval_string("{new_parameter}"));
//lr_output_message("The last buffer's is:%c/n", lr_eval_string("{ActualBuffer}"));
search_str=lr_eval_string("{name}");
//lr_output_message("name is %s",lr_eval_string("{name}"));
position = (char *)strstr(lr_eval_string("{new_parameter}"), search_str);
if (position) {
lr_output_message("you are here==========================+++++++++++++++++++++++++++++++");
lr_output_message("name is %s",lr_eval_string("{name}"));
lr_output_message("name is %s",lr_eval_string("{pwd}"));
lr_output_message("you are here==========================+++++++++++++++++++++++++++++++");
}
lrs_close_socket("socket0");