Last active
November 11, 2015 10:23
-
-
Save txomon/699ed25c8bc2b0812379 to your computer and use it in GitHub Desktop.
recvfrom 0.0.0.0
This file contains hidden or 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
unsigned int get_next_pkt(int fd, struct lx_pkt *pkt, struct sockaddr_in *si) | |
{ | |
socklen_t size_si = sizeof(struct sockaddr); | |
ssize_t bytes; | |
bytes = recvfrom(fd, pkt, 1024, 0, (struct sockaddr *) si, &size_si); | |
if (bytes < 1) { | |
return 0; | |
} | |
return (unsigned int) bytes; | |
} |
This file contains hidden or 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
static void processor() | |
{ | |
struct sockaddr_in si = {.sin_port=56700}; /* Avoid improbable null */ | |
unsigned int bytes; | |
pkt = malloc(1024); /* Enough for known packages */ | |
while ((bytes = get_next_pkt(lx_ctx->sock.fd, pkt, &si))) { | |
fprintf(stderr, "Address %u\n", si.sin_addr | |
.s_addr); | |
} | |
free(pkt); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment