Advertisement
ringneckparrot

sockaddr_in documented

Apr 9th, 2012
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.26 KB | None | 0 0
  1. /****************************************************************************
  2.     ringneckparrot (c)
  3.     License: http://creativecommons.org/licenses/by-nc-sa/3.0/
  4.    
  5.     Contact Me:
  6.     Email: ringneckparrot@hotmail.com
  7.     Facebook: http://www.facebook.com/ringneckparrot
  8.     Twitter ID: pp4rr0t
  9.     SecurityTube: http://www.securitytube.net/user/ringneckparrot
  10.  
  11. ****************************************************************************/
  12.  
  13. //Typical Header Declaration
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16.  
  17. #include <netinet/in.h> // sockaddr_in
  18. #include <strings.h> // Bzero()
  19.  
  20. main()
  21. {
  22.     struct sockaddr_in info; // Create a sockaddr_in structure and name it "info"
  23.  
  24.     info.sin_family = AF_INET; // Define the address family as AF_INET
  25.     info.sin_port = htons(1234); // Define the port as 1234, translated into Network byte order with htons()
  26.     info.sin_addr.s_addr = INADDR_ANY; // Define the interface/s from which to accept
  27.     bzero(&info.sin_zero, 8); // Zero the 8 bytes of the info.sin_zero that have to be zero
  28.  
  29.    
  30.     // This does not use any memory
  31.     // It just creates the structure
  32.     // So you can create the socket on of it
  33.     // It is not a complete program, if you compile it you won't get any errors,
  34.     // but at this present situation, this program has no actual use
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement