root / trunk / code / projects / mapping / python / server.c @ 934
History | View | Annotate | Download (732 Bytes)
| 1 | /* A simple server in the internet domain using TCP
|
|---|---|
| 2 | The port number is passed as an argument */ |
| 3 | #include <stdio.h> |
| 4 | #include <stdlib.h> |
| 5 | #include <strings.h> |
| 6 | #include <string.h> |
| 7 | #include <unistd.h> |
| 8 | #include <sys/types.h> |
| 9 | #include <sys/socket.h> |
| 10 | #include <netinet/in.h> |
| 11 | |
| 12 | #include "netserv.h" |
| 13 | #include "robots.h" |
| 14 | #include "wireless.h" |
| 15 | |
| 16 | |
| 17 | |
| 18 | int main(int argc, char *argv[]) |
| 19 | {
|
| 20 | if (argc < 2) { |
| 21 | fprintf(stderr,"usage: %s <port number>\n", argv[0]); |
| 22 | exit(1);
|
| 23 | } |
| 24 | newsockfd = make_sock(atoi(argv[1]));
|
| 25 | printf("Made socket\n");
|
| 26 | make_listener(); |
| 27 | printf("Robot listener created.\n");
|
| 28 | |
| 29 | while (1) |
| 30 | {
|
| 31 | wl_do(); |
| 32 | } |
| 33 | return 0; |
| 34 | } |
| 35 | |
| 36 | void error(char *msg) |
| 37 | {
|
| 38 | printf(msg); |
| 39 | exit(1);
|
| 40 | } |
| 41 |