Ver Fonte

added send error handling

Jiri Kuthan há 24 anos atrás
pai
commit
a4d46726bc
1 ficheiros alterados com 4 adições e 1 exclusões
  1. 4 1
      test/udp_flood.c

+ 4 - 1
test/udp_flood.c

@@ -173,7 +173,10 @@ int main (int argc, char** argv)
 	/* flood loop */
 	for (r=0; r<count; r++){
 		if ((verbose>1)&&(r%1000))  putchar('.');
-		send(sock, buf, n, 0);
+		if (send(sock, buf, n, 0)==-1) {
+			fprintf(stderr, "Error: send: %s\n",  strerror(errno));
+			exit(1);
+		}
 	}
 	printf("\n%d packets sent, %d bytes each => total %d bytes\n",
 			count, n, n*count);