Race to the Bottom: Weaponizing Concurrency , PART 1 . #THREADING
zeroday.forem.comยท5dยท
Discuss: DEV
๐Ÿ”—Concurrency Primitives
Preview
Report Post

btw im learning while creating this blog so if there is any mistake please tell me, and i will fix it and learn , THANKS !

HI i like to dive into things immediately so take a look at this code sample here :

CHAPTER 1 : THREADS ?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>

#define PORT 8080

void handle_request(int client_socket) {
char response[2048];

strcpy(response, "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n");
strcat(response, "<html><body><h1>Hi</h1>");
write(client_socket, response, strlen(response));

sleep(3);

memset(response, 0, sizeof(response));
strcat(response, "<h1>Hi again!</h1></body></html>");
write(client_socket, response, strlen(response));

close(client_socket);
}

/*---------------------...

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help