Created
August 24, 2011 22:27
-
-
Save nfarring/1169451 to your computer and use it in GitHub Desktop.
Templates for C sockets
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
#include <stdio.h> // PERROR(3) | |
#include <stdlib.h> // EXIT(3) | |
#include <sys/socket.h> // BIND(2) | |
int retval = bind( | |
/* int sockfd */ | |
/* const struct sockaddr *addr */ | |
/* socklen_t addrlen */ | |
); | |
if (retval == -1) { | |
perror("bind"); | |
exit(-1); | |
} |
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
#include <stdio.h> // PERROR(3) | |
#include <stdlib.h> // EXIT(3) | |
#include <sys/socket.h> // SOCKET(2) | |
// Raw Ethernet IPv6 | |
int sockfd = socket( | |
/* int domain */ AF_PACKET, | |
/* int type */ SOCK_RAW, | |
/* int protocol */ 0x0800 | |
); | |
if (sockfd == -1) { | |
perror("socket"); | |
exit(-1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment