My application needs to send and read IPv6 addresses over the wire. It’s only going to be read by my application, but I’d still like to follow convention. Is there a library function for doing this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
socketmodule has a function for this, called inet_pton. However, it’s not available on all platforms. (It is not available on the Windows machine I’m writing this on.)I recommend that you use a nonstandard library called ipaddr. It has two somewhat non-obvious functions that will do precisely what you need: