Skip to content

Instantly share code, notes, and snippets.

@lucas-clemente
Created October 11, 2016 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucas-clemente/437f93c71e600437b27d6996dead17f4 to your computer and use it in GitHub Desktop.
Save lucas-clemente/437f93c71e600437b27d6996dead17f4 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
int sink;
void doSomething() {
for (int i = 0; i < 1000000; ++i) {
sink += i;
}
}
int main() {
struct sockaddr_in sa;
memset(&sa, 0, sizeof(sa));
sa.sin_family = AF_INET;
sa.sin_port = htons(4242);
sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
int len = 1000;
void* buf = malloc(len);
for (int i = 0; i < 1000; i++) {
sendto(fd, buf, len, 0, &sa, sizeof(sa));
doSomething();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment