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

akash gangil gangil-guest at alioth.debian.org
Sat Jun 13 21:29:44 UTC 2009


Author: gangil-guest
Date: 2009-06-13 21:29:44 +0000 (Sat, 13 Jun 2009)
New Revision: 1044

Modified:
   tuxmath/branches/lan/server/server.c
   tuxmath/branches/lan/server/testclient.c
Log:
Now transferring individual questions(flashcards)!!!!!!!!!!!

Modified: tuxmath/branches/lan/server/server.c
===================================================================
--- tuxmath/branches/lan/server/server.c	2009-06-13 19:59:38 UTC (rev 1043)
+++ tuxmath/branches/lan/server/server.c	2009-06-13 21:29:44 UTC (rev 1044)
@@ -208,14 +208,14 @@
 //        if(*ch=='1')
 //        { 
 
-       x=SDLNet_TCP_Send(csd,fc->answer_string,strlen(fc->answer_string));
+       x=SDLNet_TCP_Send(csd,fc->answer_string,strlen(fc->answer_string)+1);
         
        printf("no:(3):::::::Sent %d bytes\n",x);
 
 //	 SDLNet_TCP_Recv(csd,ch,1);
 //          if(*ch=='1')
 //           {
-      x=SDLNet_TCP_Send(csd,fc->formula_string,strlen(fc->formula_string));
+      x=SDLNet_TCP_Send(csd,fc->formula_string,strlen(fc->formula_string)+1);
 
        printf("no:(4):::::::Sent %d bytes\n",x);
     

Modified: tuxmath/branches/lan/server/testclient.c
===================================================================
--- tuxmath/branches/lan/server/testclient.c	2009-06-13 19:59:38 UTC (rev 1043)
+++ tuxmath/branches/lan/server/testclient.c	2009-06-13 21:29:44 UTC (rev 1044)
@@ -113,8 +113,8 @@
 
 int RecvQuestion(MC_FlashCard* fc)                           //function to receive a flashcard(question) by the client
 {
-      char *ch="1";
-      int x;
+      char ch[5];
+      int x,i=0;
 
 x=SDLNet_TCP_Recv(sd,&(fc->difficulty),sizeof(fc->difficulty));
        printf("no:(1):::::::Received %d bytes\n",x);
@@ -128,14 +128,16 @@
 
 
 //        SDLNet_TCP_Send(sd,ch,1);
-
-	x=SDLNet_TCP_Recv(sd,fc->answer_string,1);      
-       
-       printf("no:(3):::::::Received %d bytes\n",x);
+       do{
+	x=SDLNet_TCP_Recv(sd,&ch[i],1);      
+       printf("<<<%d>>>no:(3):::::::Received %d bytes\n",i,x);
+       i++;
+       }while(ch[i-1]!='\0');
+       strncpy(fc->answer_string,ch,i+1);
         printf("RECEIVED >>          %s\n",fc->answer_string);  
 
 //        SDLNet_TCP_Send(sd,ch,1);
-x=SDLNet_TCP_Recv(sd,fc->formula_string,strlen(fc->formula_string)+1);
+x=SDLNet_TCP_Recv(sd,fc->formula_string,13);
        
        printf("no:(4):::::::Received %d bytes\n",x);
         printf("RECEIVED >>          %s\n",fc->formula_string);  




More information about the Tux4kids-commits mailing list