|
莫名真的很奇妙
脚本如下:
Action()
{
buf2=lr_eval_string("<iq id=\"jcl_1\" type=\"get\"><query xmlns=\"jabber:iq:auth\"><username>{Login_Name}</username></query></iq>");
buf6b=lr_eval_string("<iq id=\"jcl_2\" type=\"set\"><query xmlns=\"jabber:iq:auth\"><username>{Login_Name}</username><resource>CTCQ</resource><compcode>81</compcode><password>");
buf6a="</password></query></iq>";
digest="670b14728ad9902aecba32e22fa4f6bd";
lr_output_message("Login_Name=%s",lr_eval_string("{Login_Name}"));
lr_output_message("This turn Port is %s",lr_eval_string("{Port}"));
lrs_create_socket("socket0", "TCP", "RemoteHost=10.80.12.137:5222", LrsLastArg);
lrs_send("socket0", "buf0", LrsLastArg);
lrs_receive("socket0", "buf1", LrsLastArg);
buf=lrs_get_received_buffer ("socket0", 0, -1, NULL);
lr_output_message("buf1 is %s",buf);
strcpy(buf,buf2);
lrs_send("socket0", "buf2", LrsLastArg);
lr_output_message("buf2 is %s",buf);
lrs_receive("socket0", "buf3", LrsLastArg);
buf=lrs_get_received_buffer("socket0",0, -1, NULL);
lr_output_message("buf3 is %s",buf);
strcpy(buf,buf6b);
strcat(buf,digest);
strcat(buf,buf6a);
lr_output_message("buf6 send ID is %d",lrs_set_send_buffer("socket0",buf,strlen(buf)));
lrs_send("socket0", "buf6", LrsLastArg);
lr_output_message("buf6 is %s",buf);
lrs_free_buffer(buf);
lrs_receive("socket0", "buf7", LrsLastArg);
buf=lrs_get_received_buffer("socket0",0, -1, NULL);
lr_output_message("buf7 is %s",buf);
lrs_send("socket0", "buf29", LrsLastArg);
lrs_send("socket0", "buf129", LrsLastArg);
lr_think_time(30);
return 0;
}
这是一个CS架构的类似QQ的软件,模拟登录过程,登录成功后发送一个包buf29给一个用户但这不是问题的重点。
运行一次没问题,迭代数目为2或者2以上就会报错,我以为应该是socket链接没有在运行完一次后关闭导致,所以我想在脚本结束之前关闭socket,下次迭代的时候再重新建立一个socket就应该没问题了。
可是我在最后面加上一句话lrs_close_socket("socket0");在runtime中设置迭代次数为2,结果运行到第二次的时候就报错了,错误日志如下:
Action.c(191): lrs_close_socket(socket0)
Action.c(191): Error: An exception was raised while calling invocation function in interpreter extension cciext.dll: System Exceptions: EXCEPTION_ACCESS_VIOLATION.
Error: An exception was raised while calling action_logic_call_vuser_run function in extension runlogic.dll: System Exceptions: EXCEPTION_ACCESS_VIOLATION.
Ending Vuser...
各位高手帮帮忙,谢谢大家!
不懂啊,为什么就不能加上这句代码呢?socket怎么才能关闭呢? |
|