我正在使用HP Loadrunner來測試套接字協議程序,現在我向服務器發送一些十六進制數字系統,但我不知道判斷套接字是否連接,我將我的腳本粘貼到這裏下面如何判斷插座是否連接?
#define _EOF '#'
#include "lrs.h"
Action()
{
char *recvbuf;
int recvlen=0;
int rc;
lr_think_time(1000);
lr_start_transaction("Trans_socket");
lrs_set_recv_timeout (1,500);
lr_start_transaction("Conn_socket");
rc = lrs_create_socket("socket0", "TCP", "LocalHost=0", "RemoteHost=192.168.10.110:10001", 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);
lr_rendezvous("trace");
lrs_send("socket0","buf0", LrsLastArg);
lrs_receive ("socket0","buf1",LrsLastArg);
lrs_get_last_received_buffer ("socket0",&recvbuf,&recvlen);
if(recvlen==58)
lr_end_transaction("Trans_socket", LR_PASS);
else
lr_end_transaction ("Trans_socket", LR_FAIL);
lrs_send("socket0", "buf2", LrsLastArg);
lrs_receive("socket0", "buf3", LrsLastArg);
lrs_send("socket0", "buf4", LrsLastArg);
lrs_receive("socket0", "buf5", LrsLastArg);
lr_think_time(100);
lrs_send("socket0", "buf6", LrsLastArg);
lr_think_time(1000);
lrs_receive("socket0", "buf7", LrsLastArg);
lr_think_time(1000);
lrs_send("socket0", "buf8", LrsLastArg);
lrs_receive("socket0", "buf9", LrsLastArg);
lrs_close_socket("socket0");
return 0;
}
你能告訴我腳本是如何工作的?我只想k現在如果套接字已連接,非常感謝 – voisvous
您想知道套接字對的末端是否已連接,或者對等體是否仍可到達? –
是的,你能幫我一下嗎?或者你可以舉個例子嗎?謝謝 – voisvous