#define _EOF '#' #include "lrs.h" Action() { char *recvbuf; int recvlen=0; int rc; lr_start_transaction("Trans_socket");//事务 lrs_set_recv_timeout (60,0);//接收超时时间 lr_start_transaction("Conn_socket"); //RemoteHost处填入被测程序所在服务器IP rc = lrs_create_socket("socket0", "TCP", "LocalHost=0", "RemoteHost=127.0.0.1:8808", LrsLastArg); lr_output_message("rc=%d",rc); if (rc != 0 ) { lr_end_transaction("Conn_socket", LR_FAIL); lr_end_transaction ("Trans_socket", LR_FAIL); return 0; } lr_end_transaction("Conn_socket", LR_PASS); //判断socket是否链接成功的事务 lr_rendezvous("集合点"); lrs_send("socket0","buf0", LrsLastArg); lrs_receive ("socket0","buf1",LrsLastArg); lrs_get_last_received_buffer ("socket0",&recvbuf,&recvlen); //判断报文长度是否正确 if(recvlen==304) lr_end_transaction("Trans_socket", LR_PASS); else lr_end_transaction ("Trans_socket", LR_FAIL); //判断返回信息的长度是否正确,recvlen处填入预期返回信息的长度 lrs_close_socket("socket0"); return 0; } |