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

24
third_party/libhv/unittest/socketpair_test.c vendored Executable file
View File

@@ -0,0 +1,24 @@
#include <stdio.h>
#include "hsocket.h"
int main(int argc, char* argv[]) {
int sockfds[2];
if (Socketpair(AF_INET, SOCK_STREAM, 0, sockfds) != 0) {
printf("socketpair failed!\n");
return -1;
}
printf("Socketpair %d<=>%d\n", sockfds[0], sockfds[1]);
char sendbuf[] = "hello,world!";
char recvbuf[1460];
int nsend = send(sockfds[0], sendbuf, strlen(sendbuf), 0);
printf("sockfd:%d send %d bytes: %s\n", sockfds[0], nsend, sendbuf);
memset(recvbuf, 0, sizeof(recvbuf));
int nrecv = recv(sockfds[1], recvbuf, sizeof(recvbuf), 0);
printf("sockfd:%d recv %d bytes: %s\n", sockfds[1], nrecv, recvbuf);
closesocket(sockfds[0]);
closesocket(sockfds[1]);
return 0;
}