diff options
author | Astonex <softukitu@gmail.com> | 2013-07-30 01:27:48 +0100 |
---|---|---|
committer | Astonex <softukitu@gmail.com> | 2013-07-30 01:27:48 +0100 |
commit | 59ccce35a6afd8e98c28c26d8a53b1880cb16ba8 (patch) | |
tree | 1870f42970c945de3cfef453705f6fb0e1956121 /testing/nTox_win32.c | |
parent | 7e973c8cac08acb5724b5e1f462faf539b647a8f (diff) |
Added multi-threading so user input doens't hold up checking the network
Diffstat (limited to 'testing/nTox_win32.c')
-rw-r--r-- | testing/nTox_win32.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/testing/nTox_win32.c b/testing/nTox_win32.c index 6e71a436..51f31001 100644 --- a/testing/nTox_win32.c +++ b/testing/nTox_win32.c | |||
@@ -24,6 +24,8 @@ | |||
24 | #include "nTox_win32.h" | 24 | #include "nTox_win32.h" |
25 | #include "misc_tools.h" | 25 | #include "misc_tools.h" |
26 | 26 | ||
27 | #include <process.h> | ||
28 | |||
27 | uint8_t pending_requests[256][CLIENT_ID_SIZE]; | 29 | uint8_t pending_requests[256][CLIENT_ID_SIZE]; |
28 | uint8_t num_requests; | 30 | uint8_t num_requests; |
29 | 31 | ||
@@ -200,6 +202,15 @@ void line_eval(char* line) | |||
200 | } | 202 | } |
201 | } | 203 | } |
202 | 204 | ||
205 | void get_input() | ||
206 | { | ||
207 | while(1) { | ||
208 | fgets(line, STRING_LENGTH, stdin); | ||
209 | line_eval(line); | ||
210 | strcpy(line, ""); | ||
211 | } | ||
212 | } | ||
213 | |||
203 | int main(int argc, char *argv[]) | 214 | int main(int argc, char *argv[]) |
204 | { | 215 | { |
205 | if (argc < 4) { | 216 | if (argc < 4) { |
@@ -264,6 +275,8 @@ int main(int argc, char *argv[]) | |||
264 | int c; | 275 | int c; |
265 | int on = 0; | 276 | int on = 0; |
266 | 277 | ||
278 | _beginthread(get_input, 0, NULL); | ||
279 | |||
267 | while(1) { | 280 | while(1) { |
268 | if (on == 0 && DHT_isconnected()) { | 281 | if (on == 0 && DHT_isconnected()) { |
269 | printf("\n[i] connected to DHT\n\n"); | 282 | printf("\n[i] connected to DHT\n\n"); |
@@ -271,12 +284,6 @@ int main(int argc, char *argv[]) | |||
271 | } | 284 | } |
272 | 285 | ||
273 | doMessenger(); | 286 | doMessenger(); |
274 | |||
275 | fgets(line, STRING_LENGTH, stdin); | ||
276 | |||
277 | line_eval(line); | ||
278 | |||
279 | strcpy(line, ""); | ||
280 | } | 287 | } |
281 | 288 | ||
282 | return 0; | 289 | return 0; |