Advertisement
ringneckparrot

bind

Apr 9th, 2012
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.10 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. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <errno.h>
  16. #include <sys/types.h>
  17. #include <sys/socket.h>
  18. #include <netinet/in.h>
  19. #include <strings.h>
  20. #define ErrorValue -1
  21.  
  22. main()
  23. {
  24.     int sock;
  25.     int bind_sock;
  26.     struct sockaddr_in bindsock;
  27.  
  28.     sock = socket(AF_INET, SOCK_STREAM, 0);
  29.     if ( sock == ErrorValue)
  30.     {
  31.         perror("Socket Error: ");
  32.         exit(-1);
  33.     }
  34.  
  35.     bzero(&bindsock, sizeof(bindsock));
  36.     bindsock.sin_family = AF_INET;
  37.     bindsock.sin_addr.s_addr = INADDR_ANY;
  38.     bindsock.sin_port = htons(1234);
  39.  
  40.  
  41.     bind_sock = bind(sock, (struct sockaddr *)&bindsock, sizeof(bindsock));
  42.     if ( bind_sock == ErrorValue)
  43.     {
  44.         perror("Bind Error: ");
  45.         exit(-1);
  46.     }
  47.    
  48.  
  49.  
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement