Where do my packets go



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

.



Relevant Pages

  • Problem with a Socket server Opening/Accepting Many sockets and the GC running.
    ... listening on port 11000 and ready to take a new connection. ... I created the Listener socket, ... THen all is well and my clients can connect for about another 3900 ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: tcpLisetener + Thread problem
    ... This is not a great solution for a couple reasons. ... clients connect, your spinning forever which wastes cpu time and on a laptop ... private readonly TcpListener listener; ... public void Start ...
    (microsoft.public.dotnet.languages.csharp)
  • Using .Net Remoting for messaging, Help Needed
    ... I am trying to build a multi clients application with C# that will send ... and receive messages using a listener on a server, ... the computers are all on the same LAN, the listener need to identify a ... ..NET remoting and appreciate any help. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Where do my packets go
    ... one thread to produce/gather data and one thread to stream the data to ... data to the listening clients. ... printf("handling listener on socket %d\n",curr); ...
    (comp.programming)
  • Re: Thread and memory consumption
    ... >> incoming data from all the clients and not a thread for each one. ... the server has a socket listener that listen for potential clients. ...
    (microsoft.public.dotnet.languages.vb)