51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2732|回复: 1
打印 上一主题 下一主题

[原创] 脚本什么地方出了错误?

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2007-5-17 15:37:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#include "lrs.h"


Action()
{

        int rc;
        char *ReceivedBuffer;
        char *buffer1;
        unsigned int len=0;
        int result;
        lrs_set_connect_timeout(10, 0);
        lrs_set_send_timeout(10,0);
        lrs_set_recv_timeout(10, 0);

        rc=lrs_create_socket("socket1", "TCP", "RemoteHost=XXXX", LrsLastArg);
        if(rc != 0)
        {
                lr_output_message("创建连接失败 %s ",rc);
                return 0;
        }

        lrs_send ("socket1", "buf1", LrsLastArg );        
        lrs_receive("socket1", "buf2", "Flags= MSG_PEEK", LrsLastArg);

        len=lrs_get_last_received_buffer_size("socket1");
        if (len < 1) {
       lr_error_message("没有任何数据收到");
       return -1 ;
        }

        ReceivedBuffer = lrs_get_received_buffer("socket1",0, len, NULL);
        lr_output_message("接收到的数据 %s ",ReceivedBuffer);

         
/*        buffer1=(char*)lrs_get_received_buffer("socket1",0, 1, NULL);
        result=strcmp(buffer1,"0");
        if(result!=0)
        {lr_error_message("预订失败");
       return -1 ;}



        lrs_save_param("socket1",NULL,"param1",2,10);
        lr_output_message ("param1: %s", lr_eval_string("{param1}"));
        lrs_save_param("socket1",NULL,"param2",3,9);
        lr_output_message ("param2: %s", lr_eval_string("{param2}"));
*/

        lrs_disable_socket("socket1", DISABLE_SEND_RECV);

        rc=lrs_close_socket("socket1");
        if (rc==0)
       {lr_output_message("Socket 1 was successfully closed "); }
        else
       {lr_error_message("An error occurred while closing the socket, Error Code: %d", rc); }


        rc=lrs_create_socket("socket1", "TCP", "RemoteHost=XXXXX", LrsLastArg);
        if(rc != 0)
        {
                lr_output_message("创建连接失败 %s ",rc);
                return 0;
        }


        lrs_send ("socket1", "buf3", LrsLastArg );        
        lrs_receive("socket1", "buf4", "Flags= MSG_PEEK", LrsLastArg);

        len=lrs_get_last_received_buffer_size("socket1");
        if (len < 1) {
       lr_error_message("没有任何数据收到");
       return -1 ;
        }

        ReceivedBuffer = lrs_get_received_buffer("socket1",0, len, NULL);
        lr_output_message("接收到的数据 %s ",ReceivedBuffer);

/*        lrs_send ("socket1", "buf5", LrsLastArg );        
        lrs_receive("socket1", "buf6", "Flags= MSG_PEEK", LrsLastArg);

        buffer1=lrs_get_received_buffer("socket1",0, 1, NULL);

        if(buffer1[0]!='t')
        {lr_error_message("取消失败");
       return -1 ;}


        ReceivedBuffer = lrs_get_received_buffer("socket1",0, len-2, NULL);
        if(len<10)
        {lr_error_message("error");
        return -1;}
        lr_output_message("接收到的数据 %s ",ReceivedBuffer);
*/

        lrs_disable_socket("socket1", DISABLE_SEND_RECV);

        rc=lrs_close_socket("socket1");
        if (rc==0)
       {lr_output_message("Socket 1 was successfully closed "); }
        else
       {lr_error_message("An error occurred while closing the socket, Error Code: %d", rc); }


    return 0;
}


;WSRData 2 1

send buf1 14
        "\x01"
                "\x06"
        "\x01"
               "0105"
                "0003"
                "dkei\tldoe"

recv buf2 7
        "1234567"
   
log

Virtual User Script started
Starting action vuser_init.
vuser_init.c(6): lrs_startup(257)
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(12): lrs_set_connect_timeout(10, 0)
Action.c(13): lrs_set_send_timeout(10, 0)
Action.c(14): lrs_set_recv_timeout(10, 0)
Action.c(16): lrs_create_socket(socket1, TCP, ...)
Action.c(23): lrs_send(socket1, buf1)
Action.c(24): lrs_receive(socket1, buf2)
Action.c(24): Error : socket1 - Connection reset by peer. Error code : 10054.
Abort was called from an action.
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2007-5-17 15:45:03 | 只看该作者
第24行
        lrs_receive("socket1", "buf2", "Flags= MSG_PEEK", LrsLastArg);


http://bbs.51testing.com/viewthread.php?tid=76250&page=1#pid525498
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-26 01:24 , Processed in 0.072090 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表