title: failure in client-server communication in c
body: <p>I am trying a C program for communication between client and server. I want my server to randomly generate an array, send it to the client and get back the sorted array from client to server. But, when I print the array sent by the server, the client shows only zeros. I guess there is problem either send function in server or receive/read function in client. Here is my code:</p>
  
  <p>Server Side:
  1- to create a random array</p>
  
  <pre><code>    //int ip[255];
      void GenIpArray()//generate random values and store in ip[]
          {
              for(int i=0;i&lt;255;i++)
                  {
                      ip[i]= rand()%100 + 100;
                  }
          }
  </code></pre>
  
  <p>2- to send array to the client</p>
  
  <pre><code>void write(LPVOID sock_fd)//int sock_fd=socket(AF_INET,SOCK_STREAM,0);
      {
          while(1)
              {
                  send((int)sock_fd,(char*)&amp;ip,255,0);
                  //let int ip[255] = {123, 109, 240, 150};
              }
      }
  </code></pre>
  
  <p>Client Side:
  1- to receive from server</p>
  
  <pre><code>void read(LPVOID sock_fd)
      {
          while(1)
              {
                  if(recv((unsigned int)sock_fd,(char*)&amp;arr,255,0)&gt;0)
                  {
                      printf("recevied: ");
                      strcpy((char*)x, (char*)arr);
                      printf("%c",(char *)&amp;x);//this statement prints @       
                      printArray();//function to print array  
                      break;
                 }
             }
      }
  </code></pre>
  
  <p>2- function to print the array</p>
  
  <pre><code>    void printArray()
          {
              printf("\n\n Printing the array:\n");
              for(int k=0;k&lt;255;k++)
                  printf("\n %d",x[k]);
          }
  </code></pre>