我还面临一些问题,即服务器向客户端发送数据,客户端发回确认。但是在经过一定的迭代后,套接字被中止,我在将确认发送回服务器时获得了WSAECONNABORTED(10053)。
我在win7 64位计算机上。
sub Send_Msg_to_SourceSelector
{
(my $msg)=@_;
my $msg_len = length("$msg")+1;
print "the message length is: $msg_len\n\n";
PrintLogFile(1, ">> $CurrentTime >> The message length is : $msg_len <<<<\n\n");
print "the SOCK1 is: SOCK\n\n";
PrintLogFile(1, ">> $CurrentTime >> The sent message is : $msg <<<<\n\n");
send $SOCK,$msg,$msg_len;
print "the SOCK2 is: $SOCK\n\n";
recv $SOCK,my $awk,3,0;
PrintLogFile(1, ">> $CurrentTime >> The acknowledgement received is : $awk <<<<\n\n");
print "the SOCK3 is: $SOCK\n\n";
}
void RecvDataFromSequencer(SOCKET sock, FILE *Log)
{
char n,buffer[2000];
while(!FlagTestExecutionCompleted)
{
memset (buffer , 0 , 2000);
printf("The address of buffer before is: %d\n", buffer);
n = recv(sock,buffer,2000,0); //blocking call
printf("The address of buffer after is: %d\n", buffer);
printf("in recv func: %x\n", Log);
//printlogfile(Log, buffer);
fprintf(Log,"%s%s",buffer,"\n");
fprintf(Log,"%d%s",n,"\n");
fprintf(Log,"%s%d%s","FlagTestExecutionCompleted is ==> ",FlagTestExecutionCompleted,"\n");
fflush(Log);
if (n == -1)
{
printf("recv failed: %d\n", WSAGetLastError());
fprintf(Log,"%s%s",WSAGetLastError(),"\n");
error("ERROR reading from STATS");
fprintf(Log,"%s%s","ERROR reading from STATS","\n");
fflush(Log);
}
else
{
printf("\nMessage from STATS: %s\n",buffer);
strcpy(line_tcfile,buffer);
if(strstr(line_tcfile,"SessionCompleted"))
{
printf("\n End of Test Session");
FlagTestExecutionCompleted=1;
}
FlagNewTestCaseRecieved = 1;
}
//Send acknowledgement
Sleep(1000);
**n = send(sock,"ACK",3,0);
if (n == -1)
{
fprintf(Log,"%s%d%s","in send command FlagTestExecutionCompleted is ==> ",FlagTestExecutionCompleted,"\n");
printf("send failed: %d\n", WSAGetLastError());
fprintf(Log,"%s%s",WSAGetLastError(),"\n");**
fprintf(Log,"%s%s","ERROR writing to STATS","\n");
fprintf(Log,"%d%s",n,"\n");
fflush(Log);
error("ERROR writing to STATS");
}
在此发生以下情况: 1.服务器读取一行并发送给客户端 2.客户端读取该行并将确认发送回服务器 3.这个过程成功地进行了一些测试 4.经过一段时间后,通过发送命令向服务器发回确认,它返回WSAECONNABORTED(10053)
我不知道是什么原因。
请帮忙
谢谢, 的Pankaj