|
录制了一段脚本。
#include "lrs.h"
#include "as_web.h"
Action()
{
int result;
char *UserBuf, *StrToLog;
int LenOfUserBuf;
char *string1 ="<?xml version=\"1.0\" encoding=\"utf-8\"?>";
char Buffer [665];
//lrs_set_connect_timeout(30, 0);
lr_start_transaction("A1");
lrs_create_socket("socket0", "TCP", "LocalHost=0", "RemoteHost=8080", LrsLastArg);
//lrs_set_send_timeout(0,1);
lr_rendezvous("adver");
lrs_set_send_timeout(2,0);
lrs_set_send_buffer("socket0",Buffer,80);
lrs_send("socket0", "buf0", LrsLastArg);
lrs_set_recv_timeout(10,0);
lrs_receive_ex("socket0", "buf1", LrsLastArg);
lrs_get_static_buffer("socket0", "buf1", 0, -1, "NULL");
LenOfUserBuf = lrs_get_user_buffer_size("socket0");
if( LenOfUserBuf == 1 )
{
lr_output_message("丢包");
lrs_close_socket("socket0");
lr_end_transaction("A1", LR_FAIL);
return -2;
}
else
{
UserBuf = lrs_get_user_buffer("socket0");
//StrToLog = (char*)malloc(LenOfUserBuf + 1); //分配所有报文的空间
StrToLog = (char*)malloc(39);
//strcpy(StrToLog, UserBuf+1); //取出所有报文
strncpy(StrToLog, UserBuf+185,39); //取出xml文档的头部
lr_output_message("S=\"%s\"",StrToLog) ;
result = strncmp( string1, StrToLog,38);
if( result==0 )
{
lr_output_message("工作正常");
lrs_close_socket("socket0");
lr_end_transaction("A1", LR_PASS);
return 0;
}
else
{
lr_output_message("访问失败");
lrs_close_socket("socket0");
lr_end_transaction("A1", LR_FAIL);
return -1;
}
}
}
运行提示所接受数据为0
Action.c(51): Mismatch (expected 1442 bytes, 0 bytes actually received)
Action.c(53): lrs_get_static_buffer(socket0, buf1, 0, -1, NULL)
Action.c(55): lrs_get_user_buffer_size(socket0) |
|