-struct timeval tv1;
-int sock_fd = -1;
-int fd = -1;
-int port = 8123;
-
-void killHandler(int i)
-{
- printf("%s caught, Bye...\n", strsignal(i));
- exit(1);
-}
-
-bool input_available(int fd){
- struct timeval tv;
- fd_set fds;
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- FD_ZERO(&fds);
- FD_SET(fd, &fds);
- if (select(fd+1, &fds, NULL, NULL, &tv) == -1)
- pdie("select");
- return FD_ISSET(fd, &fds);
-}
-
-long millis() {
- if (gettimeofday(&tv1, NULL) == -1)
- pdie("gettimeofday");
- return tv1.tv_sec*1000 + tv1.tv_usec/1000;
-}
-
-void read_message(int fd_in, int fd_out)