Update Protobuf-C to 0.14
[umurmur.git] / src / server.c
index ff20f81795b968adbca5b80cf7aa1335b310b74a..752a2006129052f89dec41afede71ddf64ae2a97 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2010, Martin Johansson <martin@fatbob.nu>
+/* Copyright (C) 2009-2010, Martin Johansson <martin@fatbob.nu>
    Copyright (C) 2005-2010, Thorvald Natvig <thorvald@natvig.com>
 
    All rights reserved.
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <stdlib.h>
 
 #include "client.h"
 #include "conf.h"
 #include "log.h"
 #include "timer.h"
+#include "version.h"
 
 #define LISTEN_SOCK 0
 #define TCP_SOCK 0
 #define UDP_SOCK 1
 
-int udpsock; /* XXX restructure! */
+/* globals */
+int udpsock; 
 bool_t shutdown_server;
 
 void Server_run()
@@ -97,11 +100,11 @@ void Server_run()
        val = 0xe0;
        rc = setsockopt(udpsock, IPPROTO_IP, IP_TOS, &val, sizeof(val));
        if (rc < 0)
-               Log_fatal("Server: Failed to set TOS for UDP Socket");
+               Log_warn("Server: Failed to set TOS for UDP Socket");
        val = 0x80;
        rc = setsockopt(udpsock, IPPROTO_IP, IP_TOS, &val, sizeof(val));
        if (rc < 0)
-               Log_fatal("Server: Failed to set TOS for UDP Socket");
+               Log_warn("Server: Failed to set TOS for UDP Socket");
        
        fcntl(udpsock, F_SETFL, O_NONBLOCK);
        pollfds[UDP_SOCK].fd = udpsock;
@@ -109,8 +112,10 @@ void Server_run()
        
        Timer_init(&janitorTimer);
        
-       Log_info("uMurmur voicechat server started -- http://code.google.com/p/umurmur/");
-
+       Log_info("uMurmur version %s protocol version %d.%d.%d",
+                        UMURMUR_VERSION, PROTVER_MAJOR, PROTVER_MINOR, PROTVER_PATCH);
+       Log_info("Visit http://code.google.com/p/umurmur/");
+       
        /* Main server loop */
        while (!shutdown_server) {
                struct sockaddr_in remote;
@@ -146,8 +151,8 @@ void Server_run()
                        tcpfd = accept(pollfds[LISTEN_SOCK].fd, (struct sockaddr*)&remote, &addrlen);
                        fcntl(tcpfd, F_SETFL, O_NONBLOCK);
                        setsockopt(tcpfd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
-                       Log_info("Connection from %s port %d\n", inet_ntoa(remote.sin_addr),
-                                        ntohs(remote.sin_port));
+                       Log_debug("Connection from %s port %d\n", inet_ntoa(remote.sin_addr),
+                                         ntohs(remote.sin_port));
                        Client_add(tcpfd, &remote);
                }