Mercurial > urweb
comparison src/c/driver.c @ 502:8875ff2e85dc
Profiling support
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 20 Nov 2008 12:16:30 -0500 |
parents | 581554f8e642 |
children | e18c747dd945 |
comparison
equal
deleted
inserted
replaced
501:7ef4b2911b09 | 502:8875ff2e85dc |
---|---|
1 #include <stdio.h> | 1 #include <stdio.h> |
2 | 2 |
3 #include <string.h> | 3 #include <string.h> |
4 #include <stdlib.h> | |
4 #include <sys/types.h> | 5 #include <sys/types.h> |
5 #include <sys/socket.h> | 6 #include <sys/socket.h> |
6 #include <netinet/in.h> | 7 #include <netinet/in.h> |
7 #include <unistd.h> | 8 #include <unistd.h> |
9 #include <signal.h> | |
8 | 10 |
9 #include <pthread.h> | 11 #include <pthread.h> |
10 | 12 |
11 #include "urweb.h" | 13 #include "urweb.h" |
12 | 14 |
295 | 297 |
296 static void help(char *cmd) { | 298 static void help(char *cmd) { |
297 printf("Usage: %s [-p <port>] [-t <thread-count>]\n", cmd); | 299 printf("Usage: %s [-p <port>] [-t <thread-count>]\n", cmd); |
298 } | 300 } |
299 | 301 |
302 static void sigint(int signum) { | |
303 printf("Exiting....\n"); | |
304 exit(0); | |
305 } | |
306 | |
300 int main(int argc, char *argv[]) { | 307 int main(int argc, char *argv[]) { |
301 // The skeleton for this function comes from Beej's sockets tutorial. | 308 // The skeleton for this function comes from Beej's sockets tutorial. |
302 int sockfd; // listen on sock_fd | 309 int sockfd; // listen on sock_fd |
303 struct sockaddr_in my_addr; | 310 struct sockaddr_in my_addr; |
304 struct sockaddr_in their_addr; // connector's address information | 311 struct sockaddr_in their_addr; // connector's address information |
305 int sin_size, yes = 1; | 312 int sin_size, yes = 1; |
306 int uw_port = 8080, nthreads = 1, i, *names, opt; | 313 int uw_port = 8080, nthreads = 1, i, *names, opt; |
307 | 314 |
315 signal(SIGINT, sigint); | |
316 | |
308 while ((opt = getopt(argc, argv, "hp:t:")) != -1) { | 317 while ((opt = getopt(argc, argv, "hp:t:")) != -1) { |
309 switch (opt) { | 318 switch (opt) { |
310 case '?': | 319 case '?': |
311 fprintf(stderr, "Unknown command-line option"); | 320 fprintf(stderr, "Unknown command-line option"); |
312 help(argv[0]); | 321 help(argv[0]); |