Skip to content

Instantly share code, notes, and snippets.

@ephemient
Created July 6, 2017 22:26
Show Gist options
  • Save ephemient/7670f4a48e6cf3e866edb801ad960c5b to your computer and use it in GitHub Desktop.
Save ephemient/7670f4a48e6cf3e866edb801ad960c5b to your computer and use it in GitHub Desktop.
#include <netinet/ip.h>
#include <string.h>
int main(int argc, const char *const *argv) {
struct sockaddr_in6 a =
{ .sin6_family = AF_INET6, .sin6_addr = IN6ADDR_LOOPBACK_INIT };
int s = socket(AF_INET6, SOCK_STREAM, 0);
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &(int) {1}, sizeof(int));
bind(s, (struct sockaddr *) &a, sizeof(a));
getsockname(s, (struct sockaddr *) &a, &(socklen_t) {sizeof(a)});
connect(s, (struct sockaddr *) &a, sizeof(a));
send(s, argv[argc > 1], strlen(argv[argc > 1]), 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment