Created
July 13, 2012 14:23
-
-
Save fatih/3105167 to your computer and use it in GitHub Desktop.
Sockaddr casting example
This file contains 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 <sys/types.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <netdb.h> | |
#include <stdio.h> | |
int main(void) | |
{ | |
struct sockaddr_in *server; | |
server->sin_family = AF_INET; | |
struct sockaddr *sa = (struct sockaddr *)server; | |
if(sa->sa_family == AF_INET) | |
printf("AF_INET\n"); | |
else | |
printf("AF_UNSPEC\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment