diff --git a/src/main.c b/src/main.c index ea13bbd..4534c95 100644 --- a/src/main.c +++ b/src/main.c @@ -28,17 +28,34 @@ #include #include +static void _print_usage () +{ + printf ("Usage: udpt \n" + "\tDefault port is 6969.\n"); +} + int main(int argc, char *argv[]) { - printf("UDP Tracker (UDPT) %s\tCopyright: (C) 2012 Naim Abda \n\n", VERSION); + printf("UDP Tracker (UDPT) %s\nCopyright: (C) 2012 Naim Abda \n\n", VERSION); #ifdef WIN32 WSADATA wsadata; WSAStartup(MAKEWORD(2, 2), &wsadata); #endif + uint16_t port = 6969; + if (argc <= 1) + { + _print_usage (); + } + else if (argc == 2) + { + port = atoi(argv[1]); + printf("selected port=%u\n", port); + } + udpServerInstance usi; - UDPTracker_init(&usi, 6969, 5); + UDPTracker_init(&usi, port, 5); int r = UDPTracker_start(&usi); if (r != 0) diff --git a/src/udpTracker.c b/src/udpTracker.c index e3ee9f8..d2c4583 100644 --- a/src/udpTracker.c +++ b/src/udpTracker.c @@ -114,7 +114,6 @@ int UDPTracker_start (udpServerInstance *usi) return 2; } - printf("SOCK=%d\n", sock); usi->sock = sock; db_open(&usi->conn, "tracker.db");