Get socket domain from descriptor(How) Can I determine the socket family from the socket file descriptorGet address family from socket. LinuxWhat is the difference between a port and a socket?How to ensure that a server listens on IPv6 if possible and IPv4 otherwise?Sending file descriptor over UNIX domain socket, and select()Comparing IPV4 socket(sockaddr_in) with IPV6 Socket(sockaddr_in6)What is best way to know if OS/platform supports IPv6 socket to listen IPv4 as well in Perl?IPV4 vs. IPV6 PHP FunctionCreating socket compatible with IPv4 and IPv6Bind both IPv4 and IPv6 source address to python socketpre-creating sockets without knowing whether they are IPv4 or IPv6Docker daemon socket configuration
How does residential electricity work?
What is the intuitive meaning of having a linear relationship between the logs of two variables?
Star/Wye electrical connection math symbol
Hostile work environment after whistle-blowing on coworker and our boss. What do I do?
Personal Teleportation as a Weapon
At which point does a character regain all their Hit Dice?
How can I replace every global instance of "x[2]" with "x_2"
How to be diplomatic in refusing to write code that breaches the privacy of our users
Applicability of Single Responsibility Principle
How will losing mobility of one hand affect my career as a programmer?
Print name if parameter passed to function
Greatest common substring
HashMap containsKey() returns false although hashCode() and equals() are true
There is only s̶i̶x̶t̶y one place he can be
Opposite of a diet
Valid Badminton Score?
Is there an Impartial Brexit Deal comparison site?
Was the picture area of a CRT a parallelogram (instead of a true rectangle)?
Hide Select Output from T-SQL
Ways to speed up user implemented RK4
How was Earth single-handedly capable of creating 3 of the 4 gods of chaos?
Is a roofing delivery truck likely to crack my driveway slab?
Go Pregnant or Go Home
Why are on-board computers allowed to change controls without notifying the pilots?
Get socket domain from descriptor
(How) Can I determine the socket family from the socket file descriptorGet address family from socket. LinuxWhat is the difference between a port and a socket?How to ensure that a server listens on IPv6 if possible and IPv4 otherwise?Sending file descriptor over UNIX domain socket, and select()Comparing IPV4 socket(sockaddr_in) with IPV6 Socket(sockaddr_in6)What is best way to know if OS/platform supports IPv6 socket to listen IPv4 as well in Perl?IPV4 vs. IPV6 PHP FunctionCreating socket compatible with IPv4 and IPv6Bind both IPv4 and IPv6 source address to python socketpre-creating sockets without knowing whether they are IPv4 or IPv6Docker daemon socket configuration
I have a socket descriptor descriptor, which has been initialized by either of the following:
- int descriptor = socket(PF_INET, SOCK_STREAM, 0);
- int descriptor = socket(PF_INET6, SOCK_STREAM, 0);
But I don't know which of the two. I would like to determine whether the socket corresponding to descriptor is an IPv4 or an IPv6 socket. I know that, for example, one can use getsockopt to determine the socket type (e.g., SOCK_STREAM vs SOCK_DGRAM) but I cannot seem to find a way to determine the socket domain (e.g., PF_INET vs PF_INET6).
c++ sockets ipv6 ipv4
add a comment |
I have a socket descriptor descriptor, which has been initialized by either of the following:
- int descriptor = socket(PF_INET, SOCK_STREAM, 0);
- int descriptor = socket(PF_INET6, SOCK_STREAM, 0);
But I don't know which of the two. I would like to determine whether the socket corresponding to descriptor is an IPv4 or an IPv6 socket. I know that, for example, one can use getsockopt to determine the socket type (e.g., SOCK_STREAM vs SOCK_DGRAM) but I cannot seem to find a way to determine the socket domain (e.g., PF_INET vs PF_INET6).
c++ sockets ipv6 ipv4
Possible duplicate of (How) Can I determine the socket family from the socket file descriptor
– Petesh
Mar 7 at 11:45
What is your platform? In linux, you can dogetsockopt(SO_DOMAIN). Seeman 7 socketfor details.
– gudok
Mar 7 at 11:45
Thank you! I’m interested in Linux and OSX.
– Matteo Monti
Mar 7 at 11:46
Another duplicate: Get address family from socket. Linux
– SKi
Mar 7 at 11:48
1
Possible duplicate of Get address family from socket. Linux
– Michael Hampton
Mar 7 at 13:35
add a comment |
I have a socket descriptor descriptor, which has been initialized by either of the following:
- int descriptor = socket(PF_INET, SOCK_STREAM, 0);
- int descriptor = socket(PF_INET6, SOCK_STREAM, 0);
But I don't know which of the two. I would like to determine whether the socket corresponding to descriptor is an IPv4 or an IPv6 socket. I know that, for example, one can use getsockopt to determine the socket type (e.g., SOCK_STREAM vs SOCK_DGRAM) but I cannot seem to find a way to determine the socket domain (e.g., PF_INET vs PF_INET6).
c++ sockets ipv6 ipv4
I have a socket descriptor descriptor, which has been initialized by either of the following:
- int descriptor = socket(PF_INET, SOCK_STREAM, 0);
- int descriptor = socket(PF_INET6, SOCK_STREAM, 0);
But I don't know which of the two. I would like to determine whether the socket corresponding to descriptor is an IPv4 or an IPv6 socket. I know that, for example, one can use getsockopt to determine the socket type (e.g., SOCK_STREAM vs SOCK_DGRAM) but I cannot seem to find a way to determine the socket domain (e.g., PF_INET vs PF_INET6).
c++ sockets ipv6 ipv4
c++ sockets ipv6 ipv4
asked Mar 7 at 11:35
Matteo MontiMatteo Monti
2,79694278
2,79694278
Possible duplicate of (How) Can I determine the socket family from the socket file descriptor
– Petesh
Mar 7 at 11:45
What is your platform? In linux, you can dogetsockopt(SO_DOMAIN). Seeman 7 socketfor details.
– gudok
Mar 7 at 11:45
Thank you! I’m interested in Linux and OSX.
– Matteo Monti
Mar 7 at 11:46
Another duplicate: Get address family from socket. Linux
– SKi
Mar 7 at 11:48
1
Possible duplicate of Get address family from socket. Linux
– Michael Hampton
Mar 7 at 13:35
add a comment |
Possible duplicate of (How) Can I determine the socket family from the socket file descriptor
– Petesh
Mar 7 at 11:45
What is your platform? In linux, you can dogetsockopt(SO_DOMAIN). Seeman 7 socketfor details.
– gudok
Mar 7 at 11:45
Thank you! I’m interested in Linux and OSX.
– Matteo Monti
Mar 7 at 11:46
Another duplicate: Get address family from socket. Linux
– SKi
Mar 7 at 11:48
1
Possible duplicate of Get address family from socket. Linux
– Michael Hampton
Mar 7 at 13:35
Possible duplicate of (How) Can I determine the socket family from the socket file descriptor
– Petesh
Mar 7 at 11:45
Possible duplicate of (How) Can I determine the socket family from the socket file descriptor
– Petesh
Mar 7 at 11:45
What is your platform? In linux, you can do
getsockopt(SO_DOMAIN). See man 7 socket for details.– gudok
Mar 7 at 11:45
What is your platform? In linux, you can do
getsockopt(SO_DOMAIN). See man 7 socket for details.– gudok
Mar 7 at 11:45
Thank you! I’m interested in Linux and OSX.
– Matteo Monti
Mar 7 at 11:46
Thank you! I’m interested in Linux and OSX.
– Matteo Monti
Mar 7 at 11:46
Another duplicate: Get address family from socket. Linux
– SKi
Mar 7 at 11:48
Another duplicate: Get address family from socket. Linux
– SKi
Mar 7 at 11:48
1
1
Possible duplicate of Get address family from socket. Linux
– Michael Hampton
Mar 7 at 13:35
Possible duplicate of Get address family from socket. Linux
– Michael Hampton
Mar 7 at 13:35
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55042835%2fget-socket-domain-from-descriptor%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55042835%2fget-socket-domain-from-descriptor%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible duplicate of (How) Can I determine the socket family from the socket file descriptor
– Petesh
Mar 7 at 11:45
What is your platform? In linux, you can do
getsockopt(SO_DOMAIN). Seeman 7 socketfor details.– gudok
Mar 7 at 11:45
Thank you! I’m interested in Linux and OSX.
– Matteo Monti
Mar 7 at 11:46
Another duplicate: Get address family from socket. Linux
– SKi
Mar 7 at 11:48
1
Possible duplicate of Get address family from socket. Linux
– Michael Hampton
Mar 7 at 13:35