Where do my packets go
- From: Till Crueger <TillFC@xxxxxxx>
- Date: Tue, 05 Sep 2006 22:36:46 +0200
Hi,
I have networked application that runs several threads. In this there is
one thread to produce/gather data and one thread to stream the data to
clients. For this system the producer sends a signal about every 10
msec that is recieved by the sending thread and triggers it to dispatch
the data to the listening clients. The code looks something like this:
while(!done) {
wait_signal(data.rcvd_data);
/* wake up and send the data accross the network */
/* build the message */
/*...*/
/* see who is waiting for data */
lock_mutex(socket_mutex);
for (curr = 0; curr<= max_fd; curr++) {
if(FD_ISSET(curr,&sockets)) {
printf("handling listener on socket %d\n",curr); /* POINT A */
nbytes = send_all(curr, msg_pckt, nbytes+HDR_LN, 0);
if(nbytes < 0) {
/* see if the connection was closed */
if(con_lost()) {
printf("Connection to listener lost\n");
}
else {
/* print out this error */
fprintf(stderr,"%s %d: %s\n",__FILE__,__LINE__,net_strerror());
}
/* close and remove our socket */
closesocket(curr);
FD_CLR(curr, &sockets);
}
}
}
unlock_mutex(socket_mutex);
}
now as soon as I connect more than one listener one of them will always
get disconnected. The output from point A suggest that this code sends
several packets to the client, but the client ussually just recieves one
or two with all the other beeing lost. After those I get a "connection
lost" message from this code. From the output I can see that all listeners
are being send data, but for some reason it seems to get lost in between.
Is there any reason why this happens? Right now I just set the SO_REUSADDR
flag on the TCP Socket I am using for this. Is there any other flag I have
to set for this to actually work?
Thanks for your help,
Till Crueger
--
Please add "Salt and Pepper" to the subject line to bypass my spam filter
.
- Follow-Ups:
- Re: Where do my packets go
- From: Till Crueger
- Re: Where do my packets go
- Prev by Date: Re: Computing in finite fields: what programming langage to choose?
- Next by Date: Re: Where do my packets go
- Previous by thread: Computing in finite fields: what programming langage to choose?
- Next by thread: Re: Where do my packets go
- Index(es):
Relevant Pages
|