summaryrefslogtreecommitdiff
path: root/testing/Lossless_UDP_testserver.c
diff options
context:
space:
mode:
Diffstat (limited to 'testing/Lossless_UDP_testserver.c')
-rw-r--r--testing/Lossless_UDP_testserver.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/testing/Lossless_UDP_testserver.c b/testing/Lossless_UDP_testserver.c
index eb506b3d..9d061c0c 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,34 @@ void printconnection(int connection_id)
147 148
148int main(int argc, char *argv[]) 149int 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
155 if (argvoffset < 0)
156 exit(1);
157
158 if (argc < argvoffset + 2) {
159 printf("Usage: %s [--ipv4|--ipv6] filename\n", argv[0]);
152 exit(0); 160 exit(0);
153 } 161 }
154 162
155 uint8_t buffer[512]; 163 uint8_t buffer[512];
156 int read; 164 int read;
157 165
158 FILE *file = fopen(argv[1], "wb"); 166 FILE *file = fopen(argv[argvoffset + 1], "wb");
159 167
160 if (file == NULL) 168 if (file == NULL) {
169 printf("Failed to open file \"%s\".\n", argv[argvoffset + 1]);
161 return 1; 170 return 1;
171 }
162 172
163 173
164 //initialize networking 174 //initialize networking
165 //bind to ip 0.0.0.0:PORT 175 //bind to ip 0.0.0.0:PORT
166 IP ip; 176 IP ip;
167 ip.uint32 = 0; 177 ip_init(&ip, ipv6enabled);
178
168 Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT)); 179 Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT));
169 perror("Initialization"); 180 perror("Initialization");
170 181