diff options
Diffstat (limited to 'testing/Lossless_UDP_testserver.c')
-rw-r--r-- | testing/Lossless_UDP_testserver.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/testing/Lossless_UDP_testserver.c b/testing/Lossless_UDP_testserver.c index eb506b3d..0fd4edd9 100644 --- a/testing/Lossless_UDP_testserver.c +++ b/testing/Lossless_UDP_testserver.c | |||
@@ -34,6 +34,7 @@ | |||
34 | 34 | ||
35 | #include "../toxcore/network.h" | 35 | #include "../toxcore/network.h" |
36 | #include "../toxcore/Lossless_UDP.h" | 36 | #include "../toxcore/Lossless_UDP.h" |
37 | #include "misc_tools.c" | ||
37 | 38 | ||
38 | //Sleep function (x = milliseconds) | 39 | //Sleep function (x = milliseconds) |
39 | #ifdef WIN32 | 40 | #ifdef WIN32 |
@@ -147,24 +148,33 @@ void printconnection(int connection_id) | |||
147 | 148 | ||
148 | int main(int argc, char *argv[]) | 149 | int main(int argc, char *argv[]) |
149 | { | 150 | { |
150 | if (argc < 2) { | 151 | /* let user override default by cmdline */ |
151 | printf("usage: %s filename\n", argv[0]); | 152 | uint8_t ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; /* x */ |
153 | int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled); | ||
154 | if (argvoffset < 0) | ||
155 | exit(1); | ||
156 | |||
157 | if (argc < argvoffset + 2) { | ||
158 | printf("Usage: %s [--ipv4|--ipv6] filename\n", argv[0]); | ||
152 | exit(0); | 159 | exit(0); |
153 | } | 160 | } |
154 | 161 | ||
155 | uint8_t buffer[512]; | 162 | uint8_t buffer[512]; |
156 | int read; | 163 | int read; |
157 | 164 | ||
158 | FILE *file = fopen(argv[1], "wb"); | 165 | FILE *file = fopen(argv[argvoffset + 1], "wb"); |
159 | 166 | ||
160 | if (file == NULL) | 167 | if (file == NULL) { |
168 | printf("Failed to open file \"%s\".\n", argv[argvoffset + 1]); | ||
161 | return 1; | 169 | return 1; |
170 | } | ||
162 | 171 | ||
163 | 172 | ||
164 | //initialize networking | 173 | //initialize networking |
165 | //bind to ip 0.0.0.0:PORT | 174 | //bind to ip 0.0.0.0:PORT |
166 | IP ip; | 175 | IP ip; |
167 | ip.uint32 = 0; | 176 | ip_init(&ip, ipv6enabled); |
177 | |||
168 | Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT)); | 178 | Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT)); |
169 | perror("Initialization"); | 179 | perror("Initialization"); |
170 | 180 | ||