patrickkonsor 0 Newbie Poster

Hello all,

I'm working on a school project (in C) that I'm having some issues with. I have a number of threads which recursively send information between one another via sockets. The structure for the recursive case is as follows..

Loop For A Long Time {
Receive From Predecessor
Respond To Predecessor
Process Info
Create Successor If Necessary
Send To Successor
Wait For Response From Successor
}

The first thread just processes info, sends it to the info, and waits for a response. The last thread just receives and processes info.

I'm having a problem that results from the following sequence of events (call a given thread B, its predecessor A, and its successor C): B sends some info to C and waits for a response, then A gets the CPU, computes some info, sends it to B, and waits for a response. At this point both A and B are blocking, so C goes and responds to B. Then B tries to get the info that A sent it. The problem is that sometimes the messages that A sent to B is no longer there (B receives something, because it stops blocking, but its zero length). B has separate sockets for A and C, so I don't believe any problem should arise from the fact that C sends a message to B (that is, B receives it as well) while A has a message that's waiting to be received by B. It would seem this is caused by a race condition, but there's no shared data that are written to.

Does anyone have any ideas as to why this might be happening?

The entirety of the code follows (it's quite long, sorry). The main is essentially a server that creates the new threads. sieve_thread is the recursive case, and every one runs in its own thread. initial is the base case, and runs in its own thread.

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include <math.h>
#include <semaphore.h>
#include <signal.h>

#define PORT 57102
#define MSG_LENGTH 1000
#define LIST_LENGTH 500
#define RESULTS_LENGTH 1000000

int max;
int max_sqrt;

int done = -1;
int cont = 1;
int new = 0;

sem_t sem1;
sem_t sem2;
int most_recent_port = PORT;

void sieve_thread(void*);
void initial();

int main(int argc, char* argv[]) {

        char msg[MSG_LENGTH];
        int socket_main, socket_current, cc, fromlen, tolen;
        int addrlen;
        struct sockaddr_in me;
        struct sockaddr_in them;
        int result, response;
        int stop = 0;
        int yes = 1;

        sem_init(&sem1, 0, 0);
        sem_init(&sem2, 0, 0);

        sigset(SIGPIPE, SIG_IGN);

        // Get Socket
        socket_main = socket(AF_INET, SOCK_STREAM, 0);
        if (socket_main == -1) {
                perror("socket");
                exit(1);
        }
        if (setsockopt(socket_main, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
                perror("setsockopt");
                close(socket_main);
                exit(1);
        }

        // Build My Struct
        memset(&me, 0, sizeof(me));
        me.sin_family = AF_INET;
        me.sin_addr.s_addr = INADDR_ANY;
        me.sin_port = htons(PORT);

        // Bind
        printf("server bound to %i\n", PORT);
        result = bind(socket_main, (struct sockaddr *) &me, sizeof(struct sockaddr));
        if (result == -1) {
                perror("bind");
                close(socket_main);
                exit(1);
        }

        // Listen
        result = listen(socket_main, 20);
        if (result == -1) {
                perror("listen");
                close(socket_main);
                exit(1);
        }

        if (argc > 1) {
                max = atoi(argv[1]);
                pthread_t thread;
                pthread_create(&thread, NULL, (void*) &initial, NULL);
        }

        sem_wait(&sem1);

        while (!stop) {

                // Accept
                result = sizeof(struct sockaddr_in);
                socket_current = accept(socket_main, (struct sockaddr*) &them, &result);
                if (socket_current == -1) {
                        perror("accept");
                        close(socket_main);
                        exit(1);
                }

                // Recieve
                result = sizeof(struct sockaddr_in);
                memset(msg, '\0', MSG_LENGTH);
                result = recvfrom(socket_current, &response, sizeof(int), 0, (struct sockaddr*) &them, &result);
                if (result == -1) {
                        perror("recv (server 1)");
                        close(socket_current);
                        close(socket_main);
                        exit(1);
                }
                printf("server recieved: %i\n", response);

                if (response > 0) {
                        max = response;
                        max_sqrt = (int) sqrt(max) + 1;
                }

                // New Thread
                if (response >= 0) {

                        pthread_t thread;
                        pthread_create(&thread, NULL, (void*) &sieve_thread, (void*) (most_recent_port + 1));
                        sem_wait(&sem2);

                        printf("server sent: %i\n", most_recent_port);
                        result = sendto(socket_current, &most_recent_port, sizeof(int), 0, (struct sockaddr*) &them, sizeof(struct sockaddr_in));
                        if (result == -1) {
                                perror("send (server 1)");
                                close(socket_current);
                                close(socket_main);
                                exit(1);
                        }

                }

                if (response == -1) {
                        stop = 1;
                }

                close(socket_current);
        }

        // Close Stuff
        //close(socket_current);
        close(socket_main);
        sleep(1);
        printf("server exiting\n");
}

// Sieve Thread
void sieve_thread(void* _port) {

        char msg[MSG_LENGTH];
        int socket_server, socket_server_sub, socket_predecessor, socket_predecessor_sub, socket_successor, socket_successor_sub;
        struct sockaddr_in me;
        struct sockaddr_in server;
        struct sockaddr_in successor;
        struct sockaddr_in predecessor;
        int result, response, response_length;
        int stop = 0, stop_all = 0;
        int list_recieve[LIST_LENGTH];
        int list_recieve_length;
        int list_send[LIST_LENGTH];
        int list_results[RESULTS_LENGTH];
        int* list_tmp;
        int list_tmp_index = 0;
        int i, j, k = 0, x = 0, yes = 1;
        int prime = 0;
        struct hostent* host;
        int created_successor = 0;
        int port = (int) _port;

        // Get Predecessor Socket
        socket_predecessor = socket(AF_INET, SOCK_STREAM, 0);
        if (socket_predecessor == -1) {
                printf("Error: socket 1 (thread %i)\n", (int) port);
                perror("socket");
                exit(1);
        }
        if (setsockopt(socket_predecessor, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
                perror("setsockopt");
                close(socket_predecessor);
                exit(1);
        }

        // Build My Struct
        memset(&me, 0, sizeof(me));
        me.sin_family = AF_INET;
        me.sin_addr.s_addr = INADDR_ANY;
        me.sin_port = htons(port);

        // Bind
        while ((result = bind(socket_predecessor, (struct sockaddr *) &me, sizeof(struct sockaddr))) == -1) {
                me.sin_port = htons(port++);
                printf("thread %i bind collision\n", port);
                //result = bind(socket_predecessor, (struct sockaddr *) &me, sizeof(struct sockaddr));
                /*if (result == -1) {
                 printf("Error: bind (thread %i)\n", (int)port);
                 perror("bind (thread 1)");
                 close(socket_predecessor);
                 exit(1);
                 }*/
        }
        most_recent_port = port;
        printf("thread bound to %i (%i)\n", port, (int)_port);

        // Listen For Predecessor
        result = listen(socket_predecessor, 20);
        if (result == -1) {
                perror("listen");
                close(socket_predecessor);
                exit(1);
        }
        printf("thread %i listening\n", (int) port);

        sem_post(&sem2);

        // Accept From Predecessor
        result = sizeof(struct sockaddr_in);
        socket_predecessor_sub = accept(socket_predecessor, (struct sockaddr*) &predecessor, &result);
        if (socket_predecessor_sub == -1) {
                printf("Error: accept (thread %i)\n", (int) port);
                perror("accept (1 in thread)");
                close(socket_predecessor);
                exit(1);
        }

        memset(list_send, 0, LIST_LENGTH);

        while (!stop) {
                printf("thread %i accepting\n", (int) port);

                // Recieve list from predecessor
                memset(list_recieve, 0, LIST_LENGTH);
                result = sizeof(struct sockaddr_in);
                response_length = recvfrom(socket_predecessor_sub, list_recieve, LIST_LENGTH * sizeof(list_recieve), 0, (struct sockaddr*) &predecessor, &result);
                if (response_length == -1) {
                        printf("Error: recv 1 (thread %i)\n", (int) port);
                        perror("recv (thread 1)");
                        close(socket_predecessor_sub);
                        close(socket_predecessor);
                        close(socket_successor_sub);
                        close(socket_successor);
                        exit(1);
                }
                printf("thread %i recieved (1): %i, length: %i\n", (int) port, list_recieve[0], response_length);

                // If our predecessor isn't done sending
                if (list_recieve[0] != -1 && response_length != 0) {
                        list_recieve_length = response_length / sizeof(int);

                        // Send response to predecessor so they can continue
                        printf("thread %i sent (1): %i\n", (int) port, cont);
                        result = sendto(socket_predecessor_sub, &cont, sizeof(cont), 0, (struct sockaddr*) &predecessor, sizeof(struct sockaddr_in));
                        if (result == -1) {
                                printf("Error: send 1 (thread %i)\n", (int) port);
                                perror("send (thread 1)");
                                close(socket_predecessor_sub);
                                close(socket_predecessor);
                                close(socket_successor_sub);
                                close(socket_successor);
                                exit(1);
                        }

                        // Set Prime
                        if (prime == 0) {
                                prime = list_recieve[0];
                                if (prime >= max_sqrt) {
                                        stop_all = 1;
                                        printf("STOP ALL (thread %i) -------------------------\n", (int) port);
                                        list_tmp = (int*) malloc(RESULTS_LENGTH * sizeof(int));
                                        memset(list_tmp, 0, RESULTS_LENGTH * sizeof(int));
                                }
                        }

                        if (!stop_all) {
                                // Update send list
                                printf("thread %i recieved entries: %i, prime: %i\n", (int) port, (response_length / sizeof(int)), prime);
                                for (i = 0; i < list_recieve_length && k < LIST_LENGTH; i++) {
                                        //printf("   thread %i testing %i\n", (int)port, list_recieve[i]);
                                        if (list_recieve[i] % prime != 0 && list_recieve > 0) {
                                                list_send[k++] = list_recieve[i];
                                        }
                                }
                        } else {
                                for (i = 0; i < list_recieve_length && k < LIST_LENGTH; i++) {
                                        //printf("   thread %i storing %i\n", (int)port, list_recieve[i]);
                                        list_tmp[list_tmp_index++] = list_recieve[i];
                                }
                        }

                } else {
                        stop = 1;
                }

                // Send list to successor
                if ((k > 1 || (stop && k > 1)) && !stop_all) {
                //if ((k == LIST_LENGTH || (stop && k > 1)) && !stop_all) {

                        // Create Successor
                        if (!created_successor) {
                                printf("thread %i creating successor\n", (int) port);

                                // Create Server Socket
                                socket_server = socket(AF_INET, SOCK_STREAM, 0);
                                if (socket_server == -1) {
                                        perror("socket");
                                        close(socket_predecessor_sub);
                                        close(socket_predecessor);
                                        exit(1);
                                }

                                // Build Server Struct
                                memset(&server, 0, sizeof(server));
                                server.sin_family = AF_INET;
                                server.sin_port = htons(PORT);
                                host = gethostbyname("mikey.cs.uwec.edu");
                                inet_aton(host->h_addr, &(server.sin_addr));

                                // Connect to Server
                                printf("thread %i connecting to %i\n", (int) port, PORT);
                                socket_server_sub = connect(socket_server, (struct sockaddr *) &server, sizeof(server));
                                if (socket_server_sub == -1) {
                                        perror("socket");
                                        close(socket_server);
                                        close(socket_predecessor_sub);
                                        close(socket_predecessor);
                                        close(socket_successor_sub);
                                        close(socket_successor);
                                        exit(1);
                                }

                                // Send Port Request to Server
                                printf("thread %i sent (2): %i\n", (int)port, new);
                                result = sendto(socket_server, &new, sizeof(new), 0, (struct sockaddr*) &server, sizeof(struct sockaddr_in));
                                if (result == -1) {
                                        printf("Error: send 2 (thread %i)\n", (int) port);
                                        perror("send (thread 2)");
                                        close(socket_server_sub);
                                        close(socket_server);
                                        close(socket_predecessor_sub);
                                        close(socket_predecessor);
                                        exit(1);
                                }

                                // Recieve Successor Port
                                result = sizeof(struct sockaddr_in);
                                result = recvfrom(socket_server, &response, sizeof(response), 0, (struct sockaddr*) &server, &result);
                                if (result == -1) {
                                        printf("Error: recv 2 (thread %i)\n", (int) port);
                                        perror("recv (thread 2)");
                                        close(socket_server_sub);
                                        close(socket_server);
                                        close(socket_predecessor_sub);
                                        close(socket_predecessor);
                                        exit(1);
                                }
                                printf("thread %i recieved (2): %i\n", (int) port, response);

                                // Disconnect From Server
                                close(socket_server_sub);
                                close(socket_server);

                                // Connect to successor if the server gave us one
                                if (response != -1) {

                                        // Create Sucessor Socket
                                        socket_successor = socket(AF_INET, SOCK_STREAM, 0);
                                        if (socket_successor == -1) {
                                                perror("socket");
                                                close(socket_predecessor_sub);
                                                close(socket_predecessor);
                                                exit(1);
                                        }

                                        // Build Successor Struct
                                        memset(&successor, 0, sizeof(successor));
                                        successor.sin_family = AF_INET;
                                        successor.sin_port = htons(response);
                                        host = gethostbyname("data.cs.uwec.edu");
                                        inet_aton(host->h_addr, &(successor.sin_addr));

                                        // Connect to Successor
                                        printf("thread %i connecting to %i\n", (int) port, response);
                                        socket_successor_sub = connect(socket_successor, (struct sockaddr *) &successor, sizeof(successor));
                                        if (socket_successor_sub == -1) {
                                                perror("socket");
                                                close(socket_predecessor_sub);
                                                close(socket_predecessor);
                                                close(socket_successor);
                                                exit(1);
                                        }
                                }

                                created_successor = 1;
                        }

                        if (created_successor) {

                                // Send list to successor
                                printf("thread %i sent (3): %i, length: %i\n", (int) port, list_send[0], k * sizeof(int));
                                result = sendto(socket_successor, list_send, k * sizeof(int), 0, (struct sockaddr*) &successor, sizeof(struct sockaddr_in));
                                if (result == -1) {
                                        printf("Error: send 3 (thread %i)\n", (int) port);
                                        perror("send (thread 3)");
                                        close(socket_predecessor_sub);
                                        close(socket_predecessor);
                                        close(socket_successor_sub);
                                        close(socket_successor);
                                        exit(1);
                                }

                                // Get Response
                                result = sizeof(struct sockaddr_in);
                                result = recvfrom(socket_successor, &response, sizeof(int), 0, (struct sockaddr*) &successor, &result);
                                if (result == -1) {
                                        printf("Error: recv 3 (thread %i)\n", (int) port);
                                        perror("recv (thread 3)");
                                        close(socket_predecessor_sub);
                                        close(socket_predecessor);
                                        close(socket_successor_sub);
                                        close(socket_successor);
                                        exit(1);
                                }
                                printf("thread %i recieved (3): %i\n", (int) port, response);

                                k = 0;
                                memset(list_send, 0, LIST_LENGTH);

                        }
                }

        }
        printf("thread %i done with loop\n", (int) port);

        // Prepare Results
        memset(list_results, 0, RESULTS_LENGTH * sizeof(int));

        // If not last
        if (created_successor) {

                // Send done signal to successor
                printf("thread %i sent (4): %i\n", port, done);
                result = sendto(socket_successor, &done, sizeof(int), 0, (struct sockaddr*) &successor, sizeof(struct sockaddr_in));
                if (result == -1) {
                        printf("Error: send 4 (thread %i)\n", (int) port);
                        perror("send (thread 4)");
                        close(socket_predecessor_sub);
                        close(socket_predecessor);
                        close(socket_successor_sub);
                        close(socket_successor);
                        exit(1);
                }

                // Wait for successors results
                printf("thread %i waiting\n", (int) port);
                result = sizeof(struct sockaddr_in);
                response_length = recvfrom(socket_successor, &list_results, RESULTS_LENGTH * sizeof(int), 0, (struct sockaddr*) &successor, &result);
                if (response_length == -1) {
                        printf("Error: recv 4 (thread %i)\n", (int) port);
                        perror("recv (thread 4)");
                        close(socket_predecessor_sub);
                        close(socket_predecessor);
                        close(socket_successor_sub);
                        close(socket_successor);
                        exit(1);
                }
                printf("thread %i recieved (4): %i, length: %i\n", (int) port,
                                list_results[0], response_length);
                k = response_length / sizeof(int) + 1;
                list_results[k - 1] = prime;
                printf("appending prime: %i\n", prime);
        }

        // If last, add all that remains in list
        else {
                printf("thread %i creating results list\n", (int) port);
                k = 0;
                for (i = list_tmp_index - 1; i > 0; i--) {
                        printf("PRIME: %i\n", list_results[i]);
                        list_results[k++] = list_tmp[i];
                }
                printf("PRIME: %i\n", prime);
                list_results[k++] = prime;
        }

        // Send results to predecessor
        printf("thread %i sent (5): %i, length: %i\n", (int) port, list_results[0], k * sizeof(int));
        result = sendto(socket_predecessor_sub, &list_results, k * sizeof(int), 0, (struct sockaddr*) &predecessor, sizeof(struct sockaddr_in));
        if (result == -1) {
                printf("Error: send 5 (thread %i)\n", (int) port);
                perror("send (thread 5)");
                close(socket_successor_sub);
                close(socket_successor);
                close(socket_predecessor_sub);
                close(socket_predecessor);
                exit(1);
        }

        close(socket_successor_sub);
        close(socket_successor);
        close(socket_predecessor_sub);
        close(socket_predecessor);

        printf("thread %i exiting\n", (int) port);
}

void initial() {
        int socket_main, socket_server, socket_thread;
        struct sockaddr_in server, thread;
        struct hostent* host;
        int result, response, i, j, k;
        int yes = 1;
        char msg[MSG_LENGTH];
        int list[LIST_LENGTH];
        int list_results[RESULTS_LENGTH];

        // Create Server Socket
        socket_main = socket(AF_INET, SOCK_STREAM, 0);
        if (socket_main == -1) {
                perror("socket");
                exit(1);
        }

        // Build Server Struct
        memset(&server, 0, sizeof(server));
        server.sin_family = AF_INET;
        server.sin_port = htons(PORT);
        host = gethostbyname("mikey.cs.uwec.edu");
        inet_aton(host->h_addr, &(server.sin_addr));

        // Connect to Server
        printf("base connecting to %i\n", PORT);
        socket_server = connect(socket_main, (struct sockaddr *) &server, sizeof(server));
        if (socket_server == -1) {
                perror("socket");
                close(socket_main);
                exit(1);
        }

        // Send Port Request to Server
        printf("base sent: %i\n", max);
        result = sendto(socket_main, &max, sizeof(max), 0, (struct sockaddr*) &server, sizeof(struct sockaddr_in));
        if (result == -1) {
                perror("send (base 1)");
                close(socket_server);
                close(socket_main);
                exit(1);
        }

        sem_post(&sem1);

        // Recieve Port
        result = sizeof(struct sockaddr_in);
        result = recvfrom(socket_main, &response, sizeof(response), 0, (struct sockaddr*) &server, &result);
        if (result == -1) {
                perror("recv (base 1)");
                close(socket_server);
                close(socket_main);
                exit(1);
        }
        printf("base recieved (1): %i\n", response);

        // Disconnect
        close(socket_server);
        close(socket_main);

        // Create Thread Socket
        socket_main = socket(AF_INET, SOCK_STREAM, 0);
        if (socket_main == -1) {
                perror("socket");
                exit(1);
        }

        // Build Thread Struct
        memset(&thread, 0, sizeof(thread));
        thread.sin_family = AF_INET;
        thread.sin_port = htons(response);
        host = gethostbyname("data.cs.uwec.edu");
        inet_aton(host->h_addr, &(thread.sin_addr));

        // Connect to Thread
        printf("base connecting to %i\n", response);
        socket_thread = connect(socket_main, (struct sockaddr *) &thread,
                        sizeof(thread));
        if (socket_thread == -1) {
                perror("socket");
                close(socket_main);
                exit(1);
        }

        // Build & Send List
        memset(list, 0, LIST_LENGTH);
        for (i = 2, j = 0; i <= max; i++) {
                list[j] = i;
                j++;

                // Send Message
                if (j == LIST_LENGTH) {
                        printf("base sent: %i, length: %i\n", list[0], j * sizeof(int));
                        result = sendto(socket_main, list, j * sizeof(int), 0, (struct sockaddr*) &thread, sizeof(struct sockaddr_in));
                        if (result == -1) {
                                perror("send (base 2)");
                                close(socket_thread);
                                close(socket_main);
                                exit(1);
                        }

                        // Get Response
                        result = sizeof(struct sockaddr_in);
                        result = recvfrom(socket_main, &response, sizeof(int), 0, (struct sockaddr*) &thread, &result);
                        if (result == -1) {
                                perror("recv (base 2)");
                                close(socket_thread);
                                close(socket_main);
                                exit(1);
                        }
                        printf("base recieved (2): %i\n", response);
                        memset(msg, '\0', MSG_LENGTH);

                        j = 0;
                }
        }

        // Send Message
        if (j > 0) {
                printf("base sent: %i, length: %i\n", list[0], j * sizeof(int));
                result = sendto(socket_main, list, j * sizeof(int), 0, (struct sockaddr*) &thread, sizeof(struct sockaddr_in));
                if (result == -1) {
                        perror("send (base 3)");
                        close(socket_thread);
                        close(socket_main);
                        exit(1);
                }

                // Get Response
                result = sizeof(struct sockaddr_in);
                result = recvfrom(socket_main, &response, sizeof(int), 0, (struct sockaddr*) &thread, &result);
                if (result == -1) {
                        perror("recv (base 3)");
                        close(socket_thread);
                        close(socket_main);
                        exit(1);
                }
                printf("base recieved (3): %i\n", response);

        }

        // Send Message
        printf("base sent: %i\n", done);
        result = sendto(socket_main, &done, sizeof(int), 0, (struct sockaddr*) &thread, sizeof(struct sockaddr_in));
        //result = send(socket_main, &done, sizeof(int), 0);
        if (result == -1) {
                perror("send (base 4)");
                close(socket_thread);
                close(socket_main);
                exit(1);
        } else {
                printf("base sent length: %i\n", result);
        }

        // Get Response
        printf("base waiting\n");
        result = sizeof(struct sockaddr_in);
        result = recvfrom(socket_main, &list_results, RESULTS_LENGTH * sizeof(int), 0, (struct sockaddr*) &thread, &result);
        if (result == -1) {
                perror("recv (base 4)");
                close(socket_thread);
                close(socket_main);
                exit(1);
        }

        for (i = result / sizeof(int) - 1; i >= 0; i--) {
                printf("%i\n", list_results[i]);
        }

        // Close the Sockets
        close(socket_thread);
        close(socket_main);

        // Create Thread Socket
        socket_main = socket(AF_INET, SOCK_STREAM, 0);
        if (socket_main == -1) {
                perror("socket");
                exit(1);
        }

        // Connect to Thread
        printf("base connecting to %i\n", response);
        socket_thread = connect(socket_main, (struct sockaddr *) &server, sizeof(server));
        if (socket_thread == -1) {
                perror("socket");
                close(socket_main);
                exit(1);
        }

        result = sendto(socket_main, &done, sizeof(int), 0, (struct sockaddr*) &server, sizeof(struct sockaddr_in));
        if (result == -1) {
                perror("send (base 5)");
                close(socket_server);
                close(socket_main);
                exit(1);
        }

        // Give client a chance to properly shutdown
        //      sleep(10);
        printf("base exiting\n");

}

Here is some sample output. The thread 57103 receives a 0 length message at line 63, but it should've received the 2000 byte message sent by base at line 40.

[konsorpc@mikey project3]$ sieve 2000
server bound to 57102
base connecting to 57102
base sent: 2000
server recieved: 2000
thread bound to 57103 (57103)
thread 57103 listening
server sent: 57103
base recieved (1): 57103
base connecting to 57103
base sent: 2, length: 2000
thread 57103 accepting
thread 57103 recieved (1): 2, length: 2000
thread 57103 sent (1): 1
thread 57103 recieved entries: 500, prime: 2
thread 57103 creating successor
base recieved (2): 1
base sent: 502, length: 2000
thread 57103 connecting to 57102
thread 57103 sent (2): 0
server recieved: 0
thread bound to 57104 (57104)
thread 57104 listening
server sent: 57104
thread 57103 recieved (2): 57104
thread 57103 connecting to 57104
thread 57103 sent (3): 3, length: 1000
thread 57104 accepting
thread 57104 recieved (1): 3, length: 1000
thread 57104 sent (1): 1
thread 57104 recieved entries: 250, prime: 3
thread 57104 creating successor
thread 57103 recieved (3): 1
thread 57103 accepting
thread 57103 recieved (1): 502, length: 2000
thread 57103 sent (1): 1
thread 57103 recieved entries: 500, prime: 2
thread 57103 sent (3): 503, length: 1000
base recieved (2): 1
base sent: 1002, length: 2000
thread 57104 connecting to 57102
thread 57104 sent (2): 0
server recieved: 0
thread bound to 57105 (57105)
thread 57105 listening
server sent: 57105
thread 57104 recieved (2): 57105
thread 57104 connecting to 57105
thread 57104 sent (3): 5, length: 664
thread 57105 accepting
thread 57105 recieved (1): 5, length: 664
thread 57105 sent (1): 1
thread 57105 recieved entries: 166, prime: 5
thread 57105 creating successor
thread 57104 recieved (3): 1
thread 57104 accepting
thread 57104 recieved (1): 503, length: 1000
thread 57104 sent (1): 1
thread 57104 recieved entries: 250, prime: 3
thread 57104 sent (3): 503, length: 668
thread 57103 recieved (3): 1
thread 57103 accepting
thread 57103 recieved (1): 0, length: 0
thread 57103 done with loop
thread 57105 connecting to 57102
thread 57105 sent (2): 0
server recieved: 0
thread bound to 57106 (57106)
thread 57106 listening
server sent: 57106
thread 57105 recieved (2): 57106
thread 57105 connecting to 57106
thread 57105 sent (3): 7, length: 532
thread 57106 accepting
thread 57106 recieved (1): 7, length: 532
thread 57106 sent (1): 1
thread 57106 recieved entries: 133, prime: 7
thread 57106 creating successor
thread 57105 recieved (3): 1
thread 57105 accepting
thread 57105 recieved (1): 503, length: 668
thread 57105 sent (1): 1
thread 57105 recieved entries: 167, prime: 5
thread 57105 sent (3): 503, length: 532
thread 57104 recieved (3): 1
thread 57104 accepting
thread 57104 recieved (1): 1002, length: 2000
thread 57104 sent (1): 1
thread 57104 recieved entries: 500, prime: 3
thread 57104 sent (3): 1003, length: 1332
base recieved (2): 1
base sent: 1502, length: 1996
thread 57106 connecting to 57102
thread 57106 sent (2): 0
server recieved: 0
thread bound to 57107 (57107)
thread 57107 listening
server sent: 57107
thread 57106 recieved (2): 57107
thread 57106 connecting to 57107
thread 57106 sent (3): 11, length: 456
thread 57107 accepting
thread 57107 recieved (1): 11, length: 456
thread 57107 sent (1): 1
thread 57107 recieved entries: 114, prime: 11
thread 57107 creating successor
thread 57106 recieved (3): 1
thread 57106 accepting
thread 57106 recieved (1): 503, length: 532
thread 57106 sent (1): 1
thread 57106 recieved entries: 133, prime: 7
thread 57106 sent (3): 503, length: 452
thread 57105 recieved (3): 1
thread 57105 accepting
thread 57105 recieved (1): 0, length: 0
thread 57105 done with loop
thread 57107 connecting to 57102
thread 57107 sent (2): 0
server recieved: 0
thread bound to 57108 (57108)
thread 57108 listening
server sent: 57108
thread 57107 recieved (2): 57108
thread 57107 connecting to 57108
thread 57107 sent (3): 13, length: 412
thread 57108 accepting
thread 57108 recieved (1): 13, length: 412
thread 57108 sent (1): 1
thread 57108 recieved entries: 103, prime: 13
thread 57108 creating successor
thread 57107 recieved (3): 1
thread 57107 accepting
thread 57107 recieved (1): 503, length: 452
thread 57107 sent (1): 1
thread 57107 recieved entries: 113, prime: 11
thread 57107 sent (3): 503, length: 412
thread 57106 recieved (3): 1
thread 57106 accepting
thread 1956 recieved (1): 1003, length: 3328
thread 1956 sent (1): 1
Error: send 1 (thread 1956)
send (thread 1): Bad file descriptor
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.