51Testing软件测试论坛

标题: 脚本什么地方出了错误? [打印本页]

作者: 大鸭梨    时间: 2007-5-17 15:37
标题: 脚本什么地方出了错误?
#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.
作者: shanxi    时间: 2007-5-17 15:45
第24行
        lrs_receive("socket1", "buf2", "Flags= MSG_PEEK", LrsLastArg);


http://bbs.51testing.com/viewthread.php?tid=76250&page=1#pid525498




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2