|
运行的socket脚本如下:
#include "lrs.h"
Action()
{
char *recvbuf;
int recvlen=0;
int rc;
lrs_startup(257);
lr_start_transaction("Trans_1");
lr_start_transaction("Conn_1");
rc=lrs_create_socket("socket0", "TCP", "RemoteHost=47.92.48.98:9092", LrsLastArg);//创建Socket连接;RemoteHost处填入被测程序所在服务器IP
lr_output_message("rc=%d",rc);
if (rc != 0 ) {
lr_end_transaction("Conn_1", LR_FAIL);
lr_end_transaction ("Trans_1", LR_FAIL);
return 0;
}
lr_end_transaction("Conn_1", LR_PASS); //判断socket是否链接成功的事务,0表示创建成功
lrs_send("socket0", "buf0", LrsLastArg); //发送buf0,buf0为在data.ws中定义的发送变量
lrs_receive("socket0", "buf1", LrsLastArg); //接收消息,存放在buf1中,buf1是在data.ws中定义的接收数组,注意数组长度一定要大于等于实际接收长度
lrs_get_last_received_buffer("socket0",&recvbuf,&recvlen);//把Socket最后接收的字节数组,长度放在recvlen中,内容放在recvbuf中
lr_output_message("Received:%s",lr_eval_string(recvbuf));
lr_output_message("recvlenLenth:%d",recvlen);
if(recvlen>3)
lr_end_transaction("Trans_1", LR_PASS);
else
lr_end_transaction ("Trans_1", LR_FAIL);
lrs_disable_socket("socket0", DISABLE_SEND_RECV); //禁止发送请求
lrs_close_socket("socket0");
return 0;
}
运行结果:
Received:乱码
recvlen:0
事务 "Trans_1" 以 "Fail" 状态结束
求助大神帮忙解答!!万分感谢。 |
|