(file) Return to wsock32_main.c CVS log (file) (dir) Up to [RizwankCVS] / wine4 / wine / dlls / wsock32 / tests

Diff for /wine4/wine/dlls/wsock32/tests/wsock32_main.c between version 1.19 and 1.20

version 1.19, 2005/02/23 05:18:34 version 1.20, 2005/02/23 06:07:24
Line 44 
Line 44 
 #endif #endif
  
 // clients threads to create // clients threads to create
 #define NUM_CLIENTS 5  #define NUM_CLIENTS 1500
  
 // amount of data to transfer from each client to server // amount of data to transfer from each client to server
 #define TEST_DATA_SIZE 145243 #define TEST_DATA_SIZE 145243
Line 70 
Line 70 
         int clientNum; // 1...NUM_CLIENTS         int clientNum; // 1...NUM_CLIENTS
 }; };
  
 struct Thread {  struct MyThread {
         HANDLE Handle;         HANDLE Handle;
         DWORD ID;         DWORD ID;
 }; };
Line 83 
Line 83 
 }; };
  
 static void test_Startup(void); static void test_Startup(void);
 void BlockingClient(int *serverPort);  void BlockingClient(volatile int *serverPort);
 void BlockingServer(int *port);  void BlockingServer(volatile int *port);
 static void test_ClientServerBlocking_1(void); static void test_ClientServerBlocking_1(void);
 static void test_Startup(void); static void test_Startup(void);
  
Line 121 
Line 121 
         addr->sin_port = tmpAddr.sin_port;         addr->sin_port = tmpAddr.sin_port;
 } }
  
 void BlockingClient(int *serverPort)  void BlockingClient(volatile int *serverPort)
 { {
         SOCKET sock;         SOCKET sock;
         SOCKADDR_IN client, server;         SOCKADDR_IN client, server;
Line 135 
Line 135 
  
         StartNetworkApp(SOCK_STREAM, &sock, &client);         StartNetworkApp(SOCK_STREAM, &sock, &client);
  
           //trace("client port %d\n",ntohs(client.sin_port));
   
         hp = gethostbyname("localhost");         hp = gethostbyname("localhost");
  
         // yield until server determines its random port number         // yield until server determines its random port number
Line 203 
Line 205 
         ok(bClosed,"Error closing socket");         ok(bClosed,"Error closing socket");
 } }
  
 void BlockingServer(int *port) // listens for incoming connections and accepts up to NUM_CLIENTS connections at once  void BlockingServer(volatile int *port) // listens for incoming connections and accepts up to NUM_CLIENTS connections at once
 { {
         struct ServerThread *Threads;         struct ServerThread *Threads;
         int ThreadIndex = 0;         int ThreadIndex = 0;
Line 237 
Line 239 
  
         // wait for all clients to receive data before cleaning up         // wait for all clients to receive data before cleaning up
         while (clientsDone != NUM_CLIENTS)         while (clientsDone != NUM_CLIENTS)
                 ;                  SwitchToThread();
  
         free(Threads);         free(Threads);
 } }
Line 245 
Line 247 
 static void test_ClientServerBlocking_1(void) static void test_ClientServerBlocking_1(void)
 { {
         int ThreadIndex = 0;         int ThreadIndex = 0;
         int serverPort = 0;          // tell the compiler not to optimize code relating to serverPort
         struct Thread ServerThread;          volatile int serverPort = 0;
         struct Thread *ClientThreads;          struct MyThread ServerThread;
           struct MyThread *ClientThreads;
  
         ClientThreads = malloc(sizeof(struct Thread) * NUM_CLIENTS);          ClientThreads = malloc(sizeof(struct MyThread) * NUM_CLIENTS);
         memset(ClientThreads, 0, sizeof(struct Thread) * NUM_CLIENTS);          memset(ClientThreads, 0, sizeof(struct MyThread) * NUM_CLIENTS);
  
         trace("starting main server thread\n");         trace("starting main server thread\n");
         ClientThreads[ThreadIndex].Handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) &BlockingServer, &serverPort, 0, &ClientThreads[ThreadIndex].ID);          ClientThreads[ThreadIndex].Handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) &BlockingServer, (void *) &serverPort, 0, &ClientThreads[ThreadIndex].ID);
  
         trace("starting %d client threads\n", NUM_CLIENTS);  
         for(ThreadIndex = 0; ThreadIndex < NUM_CLIENTS; ThreadIndex++) {         for(ThreadIndex = 0; ThreadIndex < NUM_CLIENTS; ThreadIndex++) {
                 ServerThread.Handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) &BlockingClient, &serverPort, 0, &ServerThread.ID);                  ServerThread.Handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) &BlockingClient, (void *) &serverPort, 0, &ServerThread.ID);
         }         }
           trace("%d clients started\n", NUM_CLIENTS);
  
           // wait for all clients to receive data before cleaning up
         while (clientsDone != NUM_CLIENTS)         while (clientsDone != NUM_CLIENTS)
                 ;                  SwitchToThread();
  
         free(ClientThreads);         free(ClientThreads);
  
Line 297 
Line 301 
   trace("test 2 of 2:\n");   trace("test 2 of 2:\n");
   test_ClientServerBlocking_1();   test_ClientServerBlocking_1();
   trace("all tests done\n");   trace("all tests done\n");
   
           // wait for all clients to receive data before cleaning up
         while (clientsDone != NUM_CLIENTS)         while (clientsDone != NUM_CLIENTS)
                 ;                  SwitchToThread();
   
         free(testData);         free(testData);
 } }


Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

Rizwan Kassim
Powered by
ViewCVS 0.9.2