ddos/client.c
changeset 0 af501b0c1716
child 9 c3fecc82ade6
new file mode 100644
--- /dev/null
+++ b/ddos/client.c
@@ -0,0 +1,52 @@
+/**
+ *     $Id: client.c,v 1.1.1.1 2008-04-28 17:32:53 mbroeker Exp $
+ * $Source: /development/c/demos/ddos/client.c,v $
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <sys/types.h>
+
+int main (int argc, char **argv)
+{
+    char message[81];
+    int client_socket;
+    struct sockaddr_in ca;
+    socklen_t size;
+    int status;
+
+    client_socket = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
+    if (client_socket == -1) {
+        perror ("socket");
+        return EXIT_FAILURE;
+    }
+
+    ca.sin_family = AF_INET;
+    ca.sin_port = htons (4000);
+    ca.sin_addr.s_addr = inet_addr ("127.0.0.1");
+
+    size = sizeof (ca);
+
+    status = connect (client_socket, (struct sockaddr *)&ca, size);
+    status = write (client_socket, "Hello\r\n", 8);
+    while (client_socket > 0) {
+        status = read (client_socket, message, 80);
+        if (status > 0) {
+            message[status] = 0;
+            printf ("SERVER RESPONS: %s", message);
+        } else {
+            perror ("READ");
+            close (client_socket);
+            return 1;
+        }
+    }
+
+    close (client_socket);
+    return 0;
+}