Author: zhu
Date: Thu Jun 23 16:03:13 2016
New Revision: 71663

URL: http://svn.reactos.org/svn/reactos?rev=71663&view=rev
Log:
Added my user-mode test programs

Added:
    branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/
    
branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/CMakeLists.txt
   (with props)
    branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/main.c   
(with props)
    branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpserver/
    
branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpserver/CMakeLists.txt
   (with props)
    branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpserver/main.c   
(with props)

Added: 
branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/CMakeLists.txt
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/CMakeLists.txt?rev=71663
==============================================================================
--- 
branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/CMakeLists.txt
    (added)
+++ 
branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/CMakeLists.txt
    [iso-8859-1] Thu Jun 23 16:03:13 2016
@@ -0,0 +1,11 @@
+
+add_definitions(-D__USE_W32_SOCKETS)
+add_executable(client main.c)
+set_module_type(client win32cui UNICODE)
+add_importlibs(client user32 ws2_32 msvcrt kernel32)
+
+if(MSVC)
+    add_importlibs(client ntdll)
+endif()
+
+add_cd_file(TARGET client DESTINATION reactos/system32 FOR all)

Propchange: 
branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/CMakeLists.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/main.c
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/main.c?rev=71663
==============================================================================
--- branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/main.c    
(added)
+++ branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/main.c    
[iso-8859-1] Thu Jun 23 16:03:13 2016
@@ -0,0 +1,49 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <winsock2.h>
+
+int wmain(int argc, LPWSTR argv[]) {
+       WSADATA wsa;
+       SOCKET sock;
+       struct sockaddr_in server;
+
+       int ret;
+       
+       char buff[256];
+
+       ret = WSAStartup(MAKEWORD(2, 2), &wsa);
+       if (ret != 0) {
+               printf("Windows Socket API Startup Failed: %d", 
WSAGetLastError());
+               return 1;
+       }
+
+       printf("Attempt socket creation\n");
+       fgets(&buff[0], 255, stdin);
+       sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+       if (sock == INVALID_SOCKET) {
+               printf("Socket Creation Failed: %d", WSAGetLastError());
+               return 1;
+       }
+       
+       server.sin_addr.s_addr = inet_addr("127.0.0.1");
+       server.sin_family = AF_INET;
+       server.sin_port = htons(10000);
+
+       printf("Attempt connect\n");
+       fgets(&buff[0], 255, stdin);
+       ret = connect(sock, (struct sockaddr *)&server, sizeof(server));
+       if (ret < 0) {
+               printf("Socket Connection Failed: %d", WSAGetLastError());
+               return 1;
+       }
+
+       printf("Connected\n");
+
+       fgets(&buff[0], 255, stdin);
+       ret = send(sock, &buff[0], 256, MSG_OOB);
+       printf("Sent %d bytes", ret);
+       
+       fgets(&buff[0], 255, stdin);
+       
+       return 0;
+}

Propchange: 
branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/main.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpserver/CMakeLists.txt
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpserver/CMakeLists.txt?rev=71663
==============================================================================
--- 
branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpserver/CMakeLists.txt
    (added)
+++ 
branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpserver/CMakeLists.txt
    [iso-8859-1] Thu Jun 23 16:03:13 2016
@@ -0,0 +1,11 @@
+
+add_definitions(-D__USE_W32_SOCKETS)
+add_executable(server main.c)
+set_module_type(server win32cui UNICODE)
+add_importlibs(server user32 ws2_32 msvcrt kernel32)
+
+if(MSVC)
+    add_importlibs(server ntdll)
+endif()
+
+add_cd_file(TARGET server DESTINATION reactos/system32 FOR all)

Propchange: 
branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpserver/CMakeLists.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpserver/main.c
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpserver/main.c?rev=71663
==============================================================================
--- branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpserver/main.c    
(added)
+++ branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpserver/main.c    
[iso-8859-1] Thu Jun 23 16:03:13 2016
@@ -0,0 +1,73 @@
+#include <stdio.h>
+#include <WinSock2.h>
+
+int wmain(int argc, LPWSTR argv[]) {
+       WSADATA wsa;
+       SOCKET sock;
+       SOCKET accepted;
+       struct sockaddr_in server;
+       struct sockaddr_in client;
+
+       int c;
+       int ret;
+       
+       char buff[256];
+
+       memset(&server, 0, sizeof(struct sockaddr_in));
+       memset(&client, 0, sizeof(struct sockaddr_in));
+
+       ret = WSAStartup(MAKEWORD(2, 2), &wsa);
+       if (ret != 0) {
+               printf("Windows Socket API Startup Failed: %d", 
WSAGetLastError());
+               exit(1);
+       }
+
+       printf("Attempt socket creation\n");
+       fgets(&buff[0], 255, stdin);
+       sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+       if (sock == INVALID_SOCKET) {
+               printf("Socket Creation Failed: %d", WSAGetLastError());
+               exit(1);
+       }
+
+       server.sin_family = AF_INET;
+       server.sin_addr.s_addr = inet_addr("127.0.0.1");
+       server.sin_port = htons(10000);
+       
+       printf("Attempt bind\n");
+       fgets(&buff[0], 255, stdin);
+       ret = bind(sock, (struct sockaddr *)&server, sizeof(server));
+       if (ret == SOCKET_ERROR) {
+               printf("Socket Bind Failed: %d", WSAGetLastError());
+               exit(1);
+       }
+
+       printf("Attempt listen\n");
+       fgets(&buff[0], 255, stdin);
+       ret = listen(sock, 3);
+       if (ret != 0) {
+               printf("Socket Listen Failed: %d", WSAGetLastError());
+               exit(1);
+       }
+
+       printf("Listening for connections on LOOPBACK port 10000\n");
+       
+       c = sizeof(struct sockaddr_in);
+
+       printf("Enter accept loop\n");
+       fgets(&buff[0], 255, stdin);
+       while(1) {
+               accepted = accept(sock, (struct sockaddr *)&client, &c);
+               if (accepted == INVALID_SOCKET) {
+                       printf("Socket Connection Acceptance Failed: %d", 
WSAGetLastError());
+                       exit(1);
+               } else {
+                       printf("Socket connection accepted\n");
+                       ret = recv(accepted, &buff[0], 256, MSG_OOB);
+                       printf("Received %d bytes\n", ret);
+                       printf("Message: %s", &buff[0]);
+               }
+       }
+
+       exit(1);
+}

Propchange: 
branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpserver/main.c
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to