(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.22 and 1.23

version 1.22, 2005/02/24 01:15:57 version 1.23, 2005/02/24 02:13:45
Line 83 
Line 83 
 }; };
  
 static void test_Startup(void); static void test_Startup(void);
 static void test_Cleanup(void);  
 void BlockingClient(volatile int *serverPort);  
 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_Cleanup(void);
   
   static void StartBlockingClients(volatile int *serverPort);
   static void BlockingClient(volatile int *serverPort);
   static void BlockingServer(volatile int *port);
   
  
 // StartNetworkApp creates socket sock of type type and returns assigned port number in addr. // StartNetworkApp creates socket sock of type type and returns assigned port number in addr.
 void StartNetworkApp(int type, SOCKET *sock, SOCKADDR_IN *addr) void StartNetworkApp(int type, SOCKET *sock, SOCKADDR_IN *addr)
Line 142 
Line 144 
  
         // yield until server determines its random port number         // yield until server determines its random port number
         while(*serverPort == 0)         while(*serverPort == 0)
                 SwitchToThread();                  Sleep(100);
  
         server.sin_family = AF_INET;         server.sin_family = AF_INET;
         server.sin_addr = *(struct in_addr *) hp->h_addr;         server.sin_addr = *(struct in_addr *) hp->h_addr;
Line 168 
Line 170 
  
                 // yield to our other threads                 // yield to our other threads
                 if(yieldCounter % 20 == 0) {                 if(yieldCounter % 20 == 0) {
                         //SwitchToThread();                          //Sleep(100);
                 }                 }
                 yieldCounter++;                 yieldCounter++;
         }         }
Line 197 
Line 199 
  
                 // yield to our other threads                 // yield to our other threads
                 if(yieldCounter % 20 == 0) {                 if(yieldCounter % 20 == 0) {
                         //SwitchToThread();                          //Sleep(100);
                 }                 }
                 yieldCounter++;                 yieldCounter++;
         }         }
Line 228 
Line 230 
         // set the port parameter; clients now know we're ready to accept connections         // set the port parameter; clients now know we're ready to accept connections
         *port = server.sin_port;         *port = server.sin_port;
  
           // bound to port; now we can start clients
           CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) &StartBlockingClients, port, 0, NULL);
   
         // we require one connection from each client thread         // we require one connection from each client thread
         for (ThreadIndex = 0; ThreadIndex < NUM_CLIENTS; ThreadIndex++) {         for (ThreadIndex = 0; ThreadIndex < NUM_CLIENTS; ThreadIndex++) {
                         // accept connection                         // accept connection
Line 240 
Line 245 
  
         // 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();                  Sleep(100);
  
         free(Threads);         free(Threads);
 } }
  
 static void test_ClientServerBlocking_1(void)  static void StartBlockingClients(volatile int *serverPort)
 { {
         int ThreadIndex = 0;         int ThreadIndex = 0;
         // tell the compiler not to optimize code relating to serverPort  
         volatile int serverPort = 0;  
         struct MyThread ServerThread;  
         struct MyThread *ClientThreads;         struct MyThread *ClientThreads;
  
         ClientThreads = malloc(sizeof(struct MyThread) * NUM_CLIENTS);         ClientThreads = malloc(sizeof(struct MyThread) * NUM_CLIENTS);
         memset(ClientThreads, 0, sizeof(struct MyThread) * NUM_CLIENTS);         memset(ClientThreads, 0, sizeof(struct MyThread) * NUM_CLIENTS);
  
         trace("starting main server thread\n");  
         ClientThreads[ThreadIndex].Handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) &BlockingServer, (void *) &serverPort, 0, &ClientThreads[ThreadIndex].ID);  
   
         for(ThreadIndex = 0; ThreadIndex < NUM_CLIENTS; ThreadIndex++) {         for(ThreadIndex = 0; ThreadIndex < NUM_CLIENTS; ThreadIndex++) {
                 ServerThread.Handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) &BlockingClient, (void *) &serverPort, 0, &ServerThread.ID);                  ClientThreads[ThreadIndex].Handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) &BlockingClient, (void *) serverPort, 0, &ClientThreads[ThreadIndex].ID);
         }         }
         trace("%d clients started\n", NUM_CLIENTS);         trace("%d clients started\n", NUM_CLIENTS);
  
         // 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();                  Sleep(100);
  
         free(ClientThreads);         free(ClientThreads);
   }
   
   static void test_ClientServerBlocking_1(void)
   {
           // tell the compiler not to optimize code relating to serverPort
           volatile int *serverPort;
           struct MyThread ServerThread;
   
           serverPort = malloc(sizeof(int));
           *serverPort = 0;
   
           // start server thread
           // server starts client threads after it binds to a port.
           trace("starting main server thread\n");
           ServerThread.Handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) &BlockingServer, (void *) serverPort, 0, &ServerThread.ID);
   
           // wait for all clients to receive data before cleaning up
           while (clientsDone != NUM_CLIENTS)
                   Sleep(100);
  
         trace("test_ClientServerBlocking_1 done\n");         trace("test_ClientServerBlocking_1 done\n");
 } }
Line 321 
Line 339 
  
   trace("all tests done\n");   trace("all tests done\n");
  
         // wait for all clients to receive data before cleaning up  
         while (clientsDone != NUM_CLIENTS)  
                 SwitchToThread();  
   
         free(testData);         free(testData);
 } }


Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

Rizwan Kassim
Powered by
ViewCVS 0.9.2