ddos/server.c
author Markus Bröker<broeker.markus@googlemail.com>
Sat, 21 Oct 2017 13:45:05 +0200
changeset 171 c6e0af68825a
parent 161 36f763c8ab16
permissions -rw-r--r--
Entrypoint and RET fixed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     1
/**
77
49e0babccb23 HEADER TAGS
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 68
diff changeset
     2
 * ddos/server.c
9
c3fecc82ade6 standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
     3
 * Copyright (C) 2008 Markus Broeker
0
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     4
 */
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     5
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     6
#include <stdio.h>
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     7
#include <stdlib.h>
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     8
#include <string.h>
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     9
#include <unistd.h>
160
26414889dded removed unneeded includes and code cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 159
diff changeset
    10
#include <sys/socket.h>
157
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    11
#include <sys/types.h>
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    12
#include <netdb.h>
160
26414889dded removed unneeded includes and code cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 159
diff changeset
    13
#include <netinet/in.h>
0
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    14
#include <signal.h>
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    15
68
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 10
diff changeset
    16
int set_proc_limit (int);
0
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    17
160
26414889dded removed unneeded includes and code cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 159
diff changeset
    18
#define SVPORT "4000"
26414889dded removed unneeded includes and code cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 159
diff changeset
    19
#define MAXLEN 1024
26414889dded removed unneeded includes and code cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 159
diff changeset
    20
#define MAXMEM 200
26414889dded removed unneeded includes and code cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 159
diff changeset
    21
157
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    22
int server_write (int client_socket, char *s)
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    23
{
160
26414889dded removed unneeded includes and code cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 159
diff changeset
    24
    if (s == NULL) {
26414889dded removed unneeded includes and code cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 159
diff changeset
    25
        fprintf (stderr, "Invalid data: s == NULL");
26414889dded removed unneeded includes and code cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 159
diff changeset
    26
        return -1;
26414889dded removed unneeded includes and code cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 159
diff changeset
    27
    }
26414889dded removed unneeded includes and code cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 159
diff changeset
    28
157
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    29
    return write (client_socket, s, strlen (s));
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    30
}
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    31
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    32
int server_init (char *port)
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    33
{
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    34
    int server_socket, status;
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    35
    struct addrinfo hints;
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    36
    struct addrinfo *result, *rp;
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    37
159
44823a881da1 set default socket options: IPV6_V6ONLY, SO_REUSEADDR
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 157
diff changeset
    38
    int yes = 1, no = 0;
157
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    39
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    40
    memset (&hints, 0, sizeof (hints));
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    41
    hints.ai_family = AF_UNSPEC;
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    42
    hints.ai_socktype = SOCK_STREAM;
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    43
    hints.ai_flags = AI_PASSIVE;
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    44
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    45
    if (getaddrinfo (NULL, "4000", &hints, &result) < 0) {
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    46
        perror ("GETADDRINFO");
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    47
        return -1;
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    48
    }
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    49
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    50
    server_socket = -1;
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    51
    for (rp = result; rp != NULL; rp = rp->ai_next) {
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    52
        if ((server_socket = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol)) < 0) {
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    53
            perror ("SOCKET");
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    54
            continue;
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    55
        }
159
44823a881da1 set default socket options: IPV6_V6ONLY, SO_REUSEADDR
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 157
diff changeset
    56
        // enable rebinding of the socket
157
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    57
        if (setsockopt (server_socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof (int)) == -1) {
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    58
            perror ("setsockopt");
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    59
            return -1;
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    60
        }
159
44823a881da1 set default socket options: IPV6_V6ONLY, SO_REUSEADDR
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 157
diff changeset
    61
        // disable IPV6ONLY, eg enable an hybrid socket
44823a881da1 set default socket options: IPV6_V6ONLY, SO_REUSEADDR
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 157
diff changeset
    62
        if (rp->ai_family == AF_INET6)
160
26414889dded removed unneeded includes and code cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 159
diff changeset
    63
            if (setsockopt (server_socket, IPPROTO_IPV6, IPV6_V6ONLY, &no, sizeof (int)) == -1)
26414889dded removed unneeded includes and code cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 159
diff changeset
    64
                perror ("setsockopt");
157
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    65
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    66
        if ((bind (server_socket, rp->ai_addr, rp->ai_addrlen)) == -1) {
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    67
            perror ("BIND");
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    68
            close (server_socket);
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    69
            server_socket = -1;
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    70
        } else {
160
26414889dded removed unneeded includes and code cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 159
diff changeset
    71
            printf ("bound to an %s socket on port %s\n", (rp->ai_family == AF_INET6) ? "IPv6" : "IPv4", port);
157
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    72
        }
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    73
    }
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    74
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    75
    status = listen (server_socket, 10);
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    76
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    77
    if (status != 0) {
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    78
        perror ("LISTEN");
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    79
        return -1;
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    80
    }
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    81
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    82
    if (result != NULL)
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    83
        freeaddrinfo (result);
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    84
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    85
    return server_socket;
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    86
}
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    87
0
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    88
int main (int argc, char **argv)
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    89
{
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    90
    int server_socket;
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    91
    int client_socket;
157
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    92
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    93
    char message[MAXLEN + 1];
0
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    94
    int len;
157
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    95
0
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    96
    pid_t pid;
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    97
    pid_t parent_pid;
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    98
160
26414889dded removed unneeded includes and code cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 159
diff changeset
    99
    if ((server_socket = server_init (SVPORT)) < 0)
0
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   100
        return EXIT_FAILURE;
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   101
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   102
    int links = 0;
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   103
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   104
    parent_pid = getpid ();
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   105
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   106
    /*
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   107
     * Child quits immediately, father mustn't wait
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   108
     */
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   109
    signal (SIGCHLD, SIG_IGN);
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   110
68
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 10
diff changeset
   111
    if (set_proc_limit (200) != 0) {
161
36f763c8ab16 spell checking: 'cannot set the limit' sounds better...
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 160
diff changeset
   112
        printf ("Cannot set the process limit\n");
0
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   113
        return EXIT_FAILURE;
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   114
    }
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   115
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   116
    for (;;) {
157
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
   117
        client_socket = accept (server_socket, NULL, NULL);
0
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   118
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   119
        printf ("PARENT PID = %d\n", parent_pid);
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   120
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   121
        pid = fork ();
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   122
        switch (pid) {
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   123
        case 0:                /* Child */
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   124
            close (server_socket);
157
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
   125
            if ((len = read (client_socket, message, MAXLEN)) == -1)
0
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   126
                break;
157
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
   127
            message[len] = '\0';
0
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   128
157
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
   129
            len = server_write (client_socket, "Please wait...\r\n");
0
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   130
            sleep (10);
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   131
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   132
            printf ("DELETING LINK [%04d] %04d\n", getpid (), links--);
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   133
            shutdown (client_socket, SHUT_RDWR);
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   134
            close (client_socket);
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   135
            return 1;
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   136
        case -1:
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   137
            perror ("Fork Error");
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   138
            close (client_socket);
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   139
            /*
157
e8fbd0653fda Simplified IPv6 aware ddos demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
   140
             * server is still alive and will continue when resources are available
0
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   141
             */
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   142
            break;
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   143
        default:               /* PID > 0 */
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   144
            close (client_socket);
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   145
            printf ("Starting LINK [%04d] %04d\n", pid, links++);
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   146
        }
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   147
    }
10
f19f44e2e863 a nice connection demo from an irc user
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 9
diff changeset
   148
f19f44e2e863 a nice connection demo from an irc user
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 9
diff changeset
   149
    return close (server_socket);
0
af501b0c1716 demos cvs copy
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   150
}