unsigned num_sources = 0;
unsigned room_sources = 0;
+unsigned num_senders = 128;
+
const static struct option longopts[] = {
{ "source-list", required_argument, NULL, 's' },
{ "destination-list", required_argument, NULL, 'd' },
}
}
+void *sender_worker(void *arg)
+{
+ printf("Dummy sender worker\n");
+ pthread_exit(0);
+}
+
void *receiver_worker(void *arg)
{
int sock = (int)arg;
int main(int argc, char **argv)
{
int server_sock;
+ unsigned i;
+ pthread_attr_t attr;
parse_options(argc, argv);
printf("Sending data on port %u from %u sources to %u destinations.\n\n",
port, num_sources, num_destinations);
+
+ // FIXME: these do not really set errno
+ if (pthread_attr_init(&attr) != 0) {
+ perror("pthread_attr_init()");
+ exit(1);
+ }
- // FIXME: fire off sender workers here
+ if (pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN + 65536 + 0x4000) != 0) {
+ perror("pthread_attr_setstacksize");
+ exit(1);
+ }
+
+ // Fire off sender workers.
+ for (i = 0; i < num_senders; ++i) {
+ pthread_t thread;
+
+ if (pthread_create(&thread, &attr, sender_worker, NULL) != 0) {
+ perror("pthread_create()");
+ exit(1);
+ }
+ }
/*
* Listen for incoming connections, spawning off one receiver
struct sockaddr_in addr;
socklen_t addr_len = sizeof(addr);
pthread_t thread;
- pthread_attr_t attr;
int sock = accept(server_sock, (struct sockaddr *)&addr, &addr_len);
if (sock == -1) {
exit(1);
}
- // FIXME: these do not really set errno
- if (pthread_attr_init(&attr) != 0) {
- perror("pthread_attr_init()");
- exit(1);
- }
-
- if (pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN + 65536 + 0x4000) != 0) {
- perror("pthread_attr_setstacksize");
- exit(1);
- }
-
if (pthread_create(&thread, &attr, receiver_worker, (void *)sock) != 0) {
perror("pthread_create()");
exit(1);