diff options
Diffstat (limited to 'toxcore/network.c')
-rw-r--r-- | toxcore/network.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/toxcore/network.c b/toxcore/network.c index b3df3fbd..e1f845d2 100644 --- a/toxcore/network.c +++ b/toxcore/network.c | |||
@@ -493,7 +493,7 @@ Networking_Core *new_networking(IP ip, uint16_t port) | |||
493 | * return Networking_Core object if no problems | 493 | * return Networking_Core object if no problems |
494 | * return NULL if there are problems. | 494 | * return NULL if there are problems. |
495 | * | 495 | * |
496 | * If error is non NULL it is set to 0 if no issues, 1 if bind failed, 2 if other. | 496 | * If error is non NULL it is set to 0 if no issues, 1 if socket related error, 2 if other. |
497 | */ | 497 | */ |
498 | Networking_Core *new_networking_ex(IP ip, uint16_t port_from, uint16_t port_to, unsigned int *error) | 498 | Networking_Core *new_networking_ex(IP ip, uint16_t port_from, uint16_t port_to, unsigned int *error) |
499 | { | 499 | { |
@@ -546,6 +546,10 @@ Networking_Core *new_networking_ex(IP ip, uint16_t port_from, uint16_t port_to, | |||
546 | fprintf(stderr, "Failed to get a socket?! %u, %s\n", errno, strerror(errno)); | 546 | fprintf(stderr, "Failed to get a socket?! %u, %s\n", errno, strerror(errno)); |
547 | #endif | 547 | #endif |
548 | free(temp); | 548 | free(temp); |
549 | |||
550 | if (error) | ||
551 | *error = 1; | ||
552 | |||
549 | return NULL; | 553 | return NULL; |
550 | } | 554 | } |
551 | 555 | ||
@@ -562,12 +566,20 @@ Networking_Core *new_networking_ex(IP ip, uint16_t port_from, uint16_t port_to, | |||
562 | /* iOS UDP sockets are weird and apparently can SIGPIPE */ | 566 | /* iOS UDP sockets are weird and apparently can SIGPIPE */ |
563 | if (!set_socket_nosigpipe(temp->sock)) { | 567 | if (!set_socket_nosigpipe(temp->sock)) { |
564 | kill_networking(temp); | 568 | kill_networking(temp); |
569 | |||
570 | if (error) | ||
571 | *error = 1; | ||
572 | |||
565 | return NULL; | 573 | return NULL; |
566 | } | 574 | } |
567 | 575 | ||
568 | /* Set socket nonblocking. */ | 576 | /* Set socket nonblocking. */ |
569 | if (!set_socket_nonblock(temp->sock)) { | 577 | if (!set_socket_nonblock(temp->sock)) { |
570 | kill_networking(temp); | 578 | kill_networking(temp); |
579 | |||
580 | if (error) | ||
581 | *error = 1; | ||
582 | |||
571 | return NULL; | 583 | return NULL; |
572 | } | 584 | } |
573 | 585 | ||