Created
May 8, 2023 20:57
-
-
Save armanbilge/46b276a2c6a121479719bb782653015e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
#include <errno.h> | |
#include <sys/mman.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <netinet/udp.h> | |
#include <arpa/inet.h> | |
#include <netdb.h> | |
#include <liburing.h> | |
int main(int argc, char *argv[]) | |
{ | |
struct io_uring ring; | |
io_uring_queue_init(8, &ring, 0); | |
int fd = socket(AF_INET, SOCK_STREAM, 0); | |
struct addrinfo * ai; | |
getaddrinfo("httpbin.org", "80", NULL, &ai); | |
connect(fd, ai->ai_addr, ai->ai_addrlen); | |
char* req = "GET /get HTTP/1.1\nHost: httpbin.org\n\n"; | |
int i; | |
for (i = 0; i < 1024 * 1024; ++i) { | |
struct io_uring_sqe *sqe = io_uring_get_sqe(&ring); | |
io_uring_prep_send(sqe, fd, req, sizeof(req) - 1, MSG_NOSIGNAL); | |
io_uring_submit(&ring); | |
} | |
sleep(600); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment