Bugfix #1: Listening port is now configurable.

Default port is 6969.
This commit is contained in:
Naim A 2012-12-06 04:11:20 +02:00
parent 8da6a3ee43
commit a4c2f83979
2 changed files with 19 additions and 3 deletions

View file

@ -28,17 +28,34 @@
#include <time.h> #include <time.h>
#include <string.h> #include <string.h>
static void _print_usage ()
{
printf ("Usage: udpt <udp-port>\n"
"\tDefault port is 6969.\n");
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
printf("UDP Tracker (UDPT) %s\tCopyright: (C) 2012 Naim Abda <naim94a@gmail.com>\n\n", VERSION); printf("UDP Tracker (UDPT) %s\nCopyright: (C) 2012 Naim Abda <naim94a@gmail.com>\n\n", VERSION);
#ifdef WIN32 #ifdef WIN32
WSADATA wsadata; WSADATA wsadata;
WSAStartup(MAKEWORD(2, 2), &wsadata); WSAStartup(MAKEWORD(2, 2), &wsadata);
#endif #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; udpServerInstance usi;
UDPTracker_init(&usi, 6969, 5); UDPTracker_init(&usi, port, 5);
int r = UDPTracker_start(&usi); int r = UDPTracker_start(&usi);
if (r != 0) if (r != 0)

View file

@ -114,7 +114,6 @@ int UDPTracker_start (udpServerInstance *usi)
return 2; return 2;
} }
printf("SOCK=%d\n", sock);
usi->sock = sock; usi->sock = sock;
db_open(&usi->conn, "tracker.db"); db_open(&usi->conn, "tracker.db");