-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
socket_create only binds to IPv6 any instead of IPv4 and IPv6 loopback #140
Comments
Oh... the reason for the changes was this: libimobiledevice/libimobiledevice-glue#40 |
Ok I know how to fix this, but I am not sure if this is the best way to do it. In https://github.com/libimobiledevice/libimobiledevice-glue/blob/fde8946a3988790fd5d3f01fc0a1fd43609ab1d1/src/socket.c#L517 diff --git a/src/socket.c b/src/socket.c
index d4dedd1..3375e5b 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -463,6 +463,7 @@ int socket_create(const char* addr, uint16_t port)
{
int sfd = -1;
int yes = 1;
+ int no = 0;
struct addrinfo hints;
struct addrinfo *result, *rp;
char portstr[8];
@@ -514,7 +515,7 @@ int socket_create(const char* addr, uint16_t port)
#if defined(AF_INET6) && defined(IPV6_V6ONLY)
if (rp->ai_family == AF_INET6) {
- if (setsockopt(sfd, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&yes, sizeof(int)) == -1) {
+ if (setsockopt(sfd, IPPROTO_IPV6, IPV6_V6ONLY, (addr) ? (void*)&yes : (void*)&no, sizeof(int)) == -1) {
perror("setsockopt() IPV6_V6ONLY");
}
} And it will make it work. It would set |
That looks great 💯 |
This commit 303ece5 uses
socket_create
to bind and listen address, however by default it seems to bind to IPv6 address only on my mac device.IPv4 loopback
IPv6 loopback
Default: IPv6 any
Env
According to the code at https://github.com/libimobiledevice/libimobiledevice-glue/blob/fde8946a3988790fd5d3f01fc0a1fd43609ab1d1/src/socket.c#L534
On my device, I will get 2 address which are
[::]:2222
and0.0.0.0:2222
by callinggetaddrinfo
, however due to thebreak
, the second address will not bebind
, which does not match the help (127.0.0.1) / commit (ipv4+ipv6) description.The text was updated successfully, but these errors were encountered: