Simple test apps for functionality checks:
authorClaudiu Mihail <claudiu.bogdan.mihail@gmail.com>
Sat, 4 Jun 2011 20:02:42 +0000 (20:02 +0000)
committerClaudiu Mihail <claudiu.bogdan.mihail@gmail.com>
Sat, 4 Jun 2011 20:02:42 +0000 (20:02 +0000)
- server.exe and client.exe do a simple exchange of messages (each sends one message to the other) and then terminate.

- server_multi.exe and client_multi.exe exchange 3 message with one another before termination.

- client_delayed.exe waits one second before sending any message to the server after a connection ahs been made (otherwise identical to client.exe)

svn path=/branches/GSoC_2011/TcpIpDriver/; revision=52082

tests/simplesocket/client.c [new file with mode: 0644]
tests/simplesocket/client.exe [new file with mode: 0644]
tests/simplesocket/client_delayed.exe [new file with mode: 0644]
tests/simplesocket/client_multi.exe [new file with mode: 0644]
tests/simplesocket/server.c [new file with mode: 0644]
tests/simplesocket/server.exe [new file with mode: 0644]
tests/simplesocket/server_multi.exe [new file with mode: 0644]

diff --git a/tests/simplesocket/client.c b/tests/simplesocket/client.c
new file mode 100644 (file)
index 0000000..00acc74
--- /dev/null
@@ -0,0 +1,70 @@
+#include <winsock2.h>
+#include <windows.h>
+#include <stdio.h>
+#include <string.h>
+
+#define PORT        54321
+#define HOST        "localhost"
+#define DIRSIZE     8192
+
+int main(int argc, char **argv)
+{
+       char hostname[100];
+       char dir[DIRSIZE];
+       int     sd;
+       struct sockaddr_in sin;
+       struct sockaddr_in pin;
+       struct hostent *hp;
+       
+       WORD version = MAKEWORD(1,1);
+       WSADATA wsaData;
+
+       WSAStartup(version, &wsaData);
+
+       strcpy(hostname, HOST);
+       if (argc>2)
+       {
+               strcpy(hostname, argv[2]);
+       }
+
+       if ((hp = gethostbyname(hostname)) == 0)
+       {
+               printf("gethostbyname error\n");
+               exit(1);
+       }
+
+       memset(&pin, 0, sizeof(pin));
+       pin.sin_family = AF_INET;
+       pin.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr;
+       pin.sin_port = htons(PORT);
+
+       if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+       {
+               printf("socket error\n");
+               exit(1);
+       }
+
+       if (connect(sd,(struct sockaddr *)  &pin, sizeof(pin)) == -1)
+       {
+               printf("connect error\n");
+               exit(1);
+       }
+
+       if (send(sd, argv[1], strlen(argv[1]), 0) == -1)
+       {
+               printf("send error\n");
+               exit(1);
+       }
+
+       if (recv(sd, dir, DIRSIZE, 0) == -1)
+       {
+               printf("recv error\n");
+               exit(1);
+       }
+
+       printf("Message from server: %s\n", dir);
+
+       close(sd);
+       
+       return 0;
+}
\ No newline at end of file
diff --git a/tests/simplesocket/client.exe b/tests/simplesocket/client.exe
new file mode 100644 (file)
index 0000000..8a89818
Binary files /dev/null and b/tests/simplesocket/client.exe differ
diff --git a/tests/simplesocket/client_delayed.exe b/tests/simplesocket/client_delayed.exe
new file mode 100644 (file)
index 0000000..b3a1281
Binary files /dev/null and b/tests/simplesocket/client_delayed.exe differ
diff --git a/tests/simplesocket/client_multi.exe b/tests/simplesocket/client_multi.exe
new file mode 100644 (file)
index 0000000..a21038c
Binary files /dev/null and b/tests/simplesocket/client_multi.exe differ
diff --git a/tests/simplesocket/server.c b/tests/simplesocket/server.c
new file mode 100644 (file)
index 0000000..5260ed0
Binary files /dev/null and b/tests/simplesocket/server.c differ
diff --git a/tests/simplesocket/server.exe b/tests/simplesocket/server.exe
new file mode 100644 (file)
index 0000000..6bcf902
Binary files /dev/null and b/tests/simplesocket/server.exe differ
diff --git a/tests/simplesocket/server_multi.exe b/tests/simplesocket/server_multi.exe
new file mode 100644 (file)
index 0000000..8d1f2e3
Binary files /dev/null and b/tests/simplesocket/server_multi.exe differ