initial commit

This commit is contained in:
2025-08-05 15:53:44 +08:00
commit 09dc02ae52
553 changed files with 137665 additions and 0 deletions

29
third_party/libhv/unittest/connect_test.c vendored Executable file
View File

@@ -0,0 +1,29 @@
#include "hsocket.h"
#include "htime.h"
int main(int argc, char* argv[]) {
if (argc < 3) {
printf("Usage: cmd ip port\n");
return -10;
}
const char* ip = argv[1];
int port = atoi(argv[2]);
unsigned int start_time = gettick_ms();
int ret = ConnectNonblock(ip, port);
unsigned int end_time = gettick_ms();
printf("ConnectNonblock[%s:%d] retval=%d cost=%ums\n", ip, port, ret, end_time-start_time);
start_time = gettick_ms();
ret = ConnectTimeout(ip, port, 3000);
end_time = gettick_ms();
printf("ConnectTimeout[%s:%d] retval=%d cost=%ums\n", ip, port, ret, end_time-start_time);
start_time = gettick_ms();
ret = Connect(ip, port, 0);
end_time = gettick_ms();
printf("ConnectBlock[%s:%d] retval=%d cost=%ums\n", ip, port, ret, end_time-start_time);
return 0;
}