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