[Tux4kids-commits] r1074 - tuxmath/branches/lan/server

akash gangil gangil-guest at alioth.debian.org
Fri Jun 19 18:34:45 UTC 2009


Author: gangil-guest
Date: 2009-06-19 18:34:44 +0000 (Fri, 19 Jun 2009)
New Revision: 1074

Modified:
   tuxmath/branches/lan/server/server.c
   tuxmath/branches/lan/server/server.h
Log:
compiling fine , Multiple clients are connected but game doesnt starts

Modified: tuxmath/branches/lan/server/server.c
===================================================================
--- tuxmath/branches/lan/server/server.c	2009-06-19 15:55:44 UTC (rev 1073)
+++ tuxmath/branches/lan/server/server.c	2009-06-19 18:34:44 UTC (rev 1074)
@@ -20,28 +20,29 @@
 #include <stdlib.h>
 #include <string.h>
  
-#include "SDL_net.h"
+#include "server.h" 
 #include "transtruct.h"
 #include "mathcards.h"
-#include "server.h" 
 
 
-TCPsocket sd; /* Socket descriptor, Client socket descriptor */
+#define NUM_CLIENTS 16
+
+TCPsocket sd; /* Socket descriptor */
 SDLNet_SocketSet client_set;
 
- 
+
+static client_type client[NUM_CLIENTS];
+
+
 int main(int argc, char **argv)
 { 
-  struct client_struct
+  int h;
+  for(h=0;h<NUM_CLIENTS;h++)
   {
-   int flag = 0;                 //flag=1 , if it has been alloted to a client, and 0 otherwise
-   TCPsocket csd;
-  }; 
+       client[h].flag=0;                          /*doing all flags = 0 meaning no clients are connected */
+   }
 
-struct client_struct client[16];
 
-
-
   IPaddress ip, *remoteIP;
   int quit, quit2;
   char buffer[NET_BUF_LEN];
@@ -96,7 +97,7 @@
   {
     /* This check the sd if there is a pending connection.
      * If there is one, accept that, and open a new socket for communicating */
-    if ((client[i].csd = SDLNet_TCP_Accept(sd)))
+    if (client[i].csd = SDLNet_TCP_Accept(sd))
     {
      num_clients++;
      /* Now we can communicate with the client using client[i].csd socket

Modified: tuxmath/branches/lan/server/server.h
===================================================================
--- tuxmath/branches/lan/server/server.h	2009-06-19 15:55:44 UTC (rev 1073)
+++ tuxmath/branches/lan/server/server.h	2009-06-19 18:34:44 UTC (rev 1074)
@@ -12,10 +12,17 @@
 */
 
 
+#include "SDL_net.h"
 
 #ifndef SERVER_H
 #define SERVER_H
+typedef struct client_type {
+  int flag;                 //flag=1 , if it has been alloted to a client, and 0 otherwise
+  TCPsocket csd;
+}client_type;
 
+  
+ 
 /*enum for commands coming from the client side*/
 enum {
   NEW_GAME,




More information about the Tux4kids-commits mailing list