Note that there are some explanatory texts on larger screens.

plurals
  1. POselect socket call send and recv synchronization
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload