about Arduino client proceed with wifly module
===

I refer Sparkfun's source code and modify it for my project below ,I have had initial client before and wish it maintain connected state without client close.



    loop{
    Package sendbuf;   //Package is a structure for converting buffer to Package struct
    sendbuf.header=0xaa;
    if (client.connect()) logon(sendbuf,client);//send msg to server request log in
    
    while (client.connected()) {
  
      //=====================================//
      //      while receive buffer           //
      //=====================================//    
      
     if (client.available()) {
         unsigned char rxBuffer[256]={};
         delay(10);
         //=======recvieve buffer process=======
         int index=-1;
         
         do{
             index++;                     
             rxBuffer[index]=client.read();           
             
             if (rxBuffer[index]==0xff)
             {
               index--;
             }
                    
         }while (client.available()); 
         
         Package* buf=(Package*)rxBuffer; 


         int result=readBufferfromServer(buf);

         if (result==2)       //result:2 mean log in success!!
         {
           security(sendbuf,client);    //send security msg to server
         }
         else if (result==1)  //result:1 mean security checking success!!
         {
           //do something
         }            

    }// end of client avaliable
    }


the procedure is: 
1.client connect success-->2.send log in msg to server-->3.sever send log in success to Arduino-->4.Arduino receive response then send security msg to server-->5.server send security success msg to Arduino ...........brabrabra...


procedure 1.~3. is ok and my problem is when I run to "4.", Arduino send security msg to server is success,but arduino receive {0xcc,0xcc,......0xcc} from arduino self .

I know 0xcc buffer receive from itself because I set break point before "5." on server ,even I go ahead the server code ,Arduino till can not receive anything from server. 



why????and how to deal with this problem????