title: select socket call send and recv synchronization
body: <p>I am using the select call and accepting the connection from "X" no of clients.
  I made duplex connection i.e. server to client and client to server.
  When connection is established between 2 entities ,I am going to send
  data in chunks from one entity to other.
  During send I read one file in chunks and send the data in chunks.</p>
  
  <pre><code>while(file_size !=0)
  {
      read_bytes = read(fd, buff, sizeof(buff));
      cnt_ = send(_sock_fd,buff,actually_read,0);
      file_size = file_size - cnt_;
      printf("total sent remaining %d : %d\n",size,actually_read);
  }
  </code></pre>
  
  <p>while at receiver side 
  //First I send the header which contain size it got accepted fine but during the following send call I used "get_readable_bytes" (Using ioctl) which returns me the no of bytes arrived at socket 
  `while(size != 0)
      {
          int test_ = 0;</p>
  
  <pre><code>    while(((cnt_= get_readable_bytes(_sock_fd))== 0) )//&amp;&amp; test_ == 0
      {
          cnt_= get_n_readable_bytes(_sock_fd);
          printf("Total bytes recved %d\n",cnt_);
          //test_ = test_ + 1;
      }
  
      while(cnt_ != 0)
      {
          actually_read = recv(_sock_fd, buff, sizeof(buff),0);
          int _cnt = get_n_readable_bytes(_sock_fd);
          printf("Total bytes recved %d\n",cnt_-_cnt);
          write(_fd,buff,actually_read);
          cnt_ = cnt_ - actually_read;
          test_ = 0;
      }
  </code></pre>
  
  <p>`Now the problem is
  1.During this execution of receive function control automatically go to the select function and it tries to execute whole receive function again so is there any way to synchronize the sender and receivers such that when the sender complete then start receiver or as soon as sender start receiver ?
  2.And how do I maintain the count of bytes sent and received.
  and this is my select call </p>
  
  <pre><code>`is_read_availble = select(maxfd + 1,&amp;read_set,NULL,NULL,&amp;timeout)`
  </code></pre>
  
  <p>with timeout 10sec.</p>