SlideShare une entreprise Scribd logo
1  sur  16
IPv6 Programming
    Eric 2012/06/29
outline

echo client

echo server

DNS conversions

refine our app to support ipv6 and ipv4

special case
ipv4 echo client
int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
struct sockaddr_in serv_addr;
memset((unsigned char *)&serv_addr, 0x00, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(9999);
inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr);

connect(sock, (struct sockaddr *)&serv_addr,
sizeof(serv_addr));
ipv6 echo client
int sock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
struct sockaddr_in6 serv_addr;
memset((unsigned char *)&serv_addr, 0x00, sizeof(serv_addr));
serv_addr.sin6_family = AF_INET6;
serv_addr.sin6_port = htons(9999);
inet_pton(AF_INET6, "::1", &serv_addr.sin6_addr);

connect(sock, (struct sockaddr *)&serv_addr,
sizeof(serv_addr));
comparison
ipv4 echo server
int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
struct sockaddr_in serv_addr;
memset((unsigned char *)&serv_addr, 0x00, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(9999);
serv_addr.sin_addr.s_addr = INADDR_ANY;
struct sockaddr_in client_addr;

bind(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
listen(sock, 20);
socklen_t len = sizeof(client_addr);
int conn = accept(sock, (struct sockaddr *)&client_addr,
&len);
ipv6 echo server
int sock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
struct sockaddr_in6 serv_addr;
memset((unsigned char *)&serv_addr, 0x00, sizeof(serv_addr));
serv_addr.sin6_family = AF_INET6;
serv_addr.sin6_port = htons(9999);
serv_addr.sin6_addr = in6addr_any;
const int on = 1;
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
struct sockaddr_in6 client_addr;

bind(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
listen(sock, 20);
socklen_t len = sizeof(client_addr);
int conn = accept(sock, (struct sockaddr *)&client_addr,
&len);
ipv4 & ipv6 echo server


 let’s see echoServer2.c

   set up 2 socket for ipv4 and ipv6
   independently.

   select is key point.
DNS conversions
please notice following functions:

  gethostbyname

  gethostbyaddr

  gethostbyname2

  inet_aton, inet_ntoa

let’s see hostent.c
hostent structure
addrinfo structure
refine our app to
support ipv6 and ipv4
grep -re “gethostby” *

grep -re “inet_ntoa” *

grep -re “inet_aton” *

grep -re “AF_INET” *

grep -re “sockaddr_in” *
special case

if our environment support ipv4 and ipv6, so

  server is simple

     ipv4 -> ipv4 socket

     ipv6 -> ipv6 socket
        const int on = 1;
        setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
        &on, sizeof(on));
special case


if our environment support ipv4 and ipv6, so

  client must consider priority of DNS
  conversions and retry connection.
special case

but......

   if our environment is ipv4 only, we should
   use hints.ai_family = AF_INET on
   getaddrinfo.

   relatively, env is ipv6 only, please enable
   hints.ai_family = AF_INET6 on getaddrinfo.
Thanks a lot.

Contenu connexe

Tendances

Rop and it's friends
Rop and it's friendsRop and it's friends
Rop and it's friendsnuc13us
 
Remote Command Execution
Remote Command ExecutionRemote Command Execution
Remote Command Executionadil raja
 
Quick Start Guide using Virtuozzo 7 (β) on AWS EC2
Quick Start Guide using Virtuozzo 7 (β) on AWS EC2Quick Start Guide using Virtuozzo 7 (β) on AWS EC2
Quick Start Guide using Virtuozzo 7 (β) on AWS EC2Kentaro Ebisawa
 
Tuga IT 2017 - Redis
Tuga IT 2017 - RedisTuga IT 2017 - Redis
Tuga IT 2017 - RedisNuno Caneco
 
Salesforce Integration using REST SOAP and HTTP callouts
Salesforce Integration using REST SOAP and HTTP calloutsSalesforce Integration using REST SOAP and HTTP callouts
Salesforce Integration using REST SOAP and HTTP calloutsRAMNARAYAN R
 

Tendances (8)

Rop and it's friends
Rop and it's friendsRop and it's friends
Rop and it's friends
 
Remote Command Execution
Remote Command ExecutionRemote Command Execution
Remote Command Execution
 
MUST CS101 Lab11
MUST CS101 Lab11 MUST CS101 Lab11
MUST CS101 Lab11
 
Quick Start Guide using Virtuozzo 7 (β) on AWS EC2
Quick Start Guide using Virtuozzo 7 (β) on AWS EC2Quick Start Guide using Virtuozzo 7 (β) on AWS EC2
Quick Start Guide using Virtuozzo 7 (β) on AWS EC2
 
Sockets intro
Sockets introSockets intro
Sockets intro
 
Tuga IT 2017 - Redis
Tuga IT 2017 - RedisTuga IT 2017 - Redis
Tuga IT 2017 - Redis
 
Npc14
Npc14Npc14
Npc14
 
Salesforce Integration using REST SOAP and HTTP callouts
Salesforce Integration using REST SOAP and HTTP calloutsSalesforce Integration using REST SOAP and HTTP callouts
Salesforce Integration using REST SOAP and HTTP callouts
 

Similaire à ipv6 programming

IPV4_IPV6_INTEROPERABILITY_
IPV4_IPV6_INTEROPERABILITY_IPV4_IPV6_INTEROPERABILITY_
IPV4_IPV6_INTEROPERABILITY_Rajesh Porwal
 
[Cisco Connect 2018 - Vietnam] Anh duc le reap the benefits of sdn with cisco...
[Cisco Connect 2018 - Vietnam] Anh duc le reap the benefits of sdn with cisco...[Cisco Connect 2018 - Vietnam] Anh duc le reap the benefits of sdn with cisco...
[Cisco Connect 2018 - Vietnam] Anh duc le reap the benefits of sdn with cisco...Nur Shiqim Chok
 
Transitioning IPv4 to IPv6
Transitioning IPv4 to IPv6Transitioning IPv4 to IPv6
Transitioning IPv4 to IPv6Jhoni Guerrero
 
Cisco CCNA EIGRP IPV6 Configuration
Cisco CCNA EIGRP IPV6 ConfigurationCisco CCNA EIGRP IPV6 Configuration
Cisco CCNA EIGRP IPV6 ConfigurationHamed Moghaddam
 
A deep dive about VIP,HAIP, and SCAN
A deep dive about VIP,HAIP, and SCAN A deep dive about VIP,HAIP, and SCAN
A deep dive about VIP,HAIP, and SCAN Riyaj Shamsudeen
 
Nat failover with dual isp on cisco router configuration explained with example
Nat failover with dual isp on cisco router configuration explained with exampleNat failover with dual isp on cisco router configuration explained with example
Nat failover with dual isp on cisco router configuration explained with exampleunixhowto
 
Morethan200ccnaquesti 140420001832-phpapp02
Morethan200ccnaquesti 140420001832-phpapp02Morethan200ccnaquesti 140420001832-phpapp02
Morethan200ccnaquesti 140420001832-phpapp02moutaz mahgoub
 
More than 200 CCNA Question Answer
More than 200 CCNA Question AnswerMore than 200 CCNA Question Answer
More than 200 CCNA Question Answerpatel_niket9
 
Nxll18 vpn (s2 s gre & dmvpn)
Nxll18 vpn (s2 s gre & dmvpn)Nxll18 vpn (s2 s gre & dmvpn)
Nxll18 vpn (s2 s gre & dmvpn)Netwax Lab
 
Cisco CCNA OSPF IPV6 Configuration
Cisco CCNA OSPF IPV6 ConfigurationCisco CCNA OSPF IPV6 Configuration
Cisco CCNA OSPF IPV6 ConfigurationHamed Moghaddam
 
Capacitacion 2018
Capacitacion 2018Capacitacion 2018
Capacitacion 2018jou333
 
OpenStack Havana over IPv6
OpenStack Havana over IPv6OpenStack Havana over IPv6
OpenStack Havana over IPv6Shixiong Shang
 
Internet Technology Practical (Mumbai University) -2017
Internet Technology Practical  (Mumbai University) -2017Internet Technology Practical  (Mumbai University) -2017
Internet Technology Practical (Mumbai University) -2017Satyendra Singh
 

Similaire à ipv6 programming (20)

IPV4_IPV6_INTEROPERABILITY_
IPV4_IPV6_INTEROPERABILITY_IPV4_IPV6_INTEROPERABILITY_
IPV4_IPV6_INTEROPERABILITY_
 
[Cisco Connect 2018 - Vietnam] Anh duc le reap the benefits of sdn with cisco...
[Cisco Connect 2018 - Vietnam] Anh duc le reap the benefits of sdn with cisco...[Cisco Connect 2018 - Vietnam] Anh duc le reap the benefits of sdn with cisco...
[Cisco Connect 2018 - Vietnam] Anh duc le reap the benefits of sdn with cisco...
 
Transitioning IPv4 to IPv6
Transitioning IPv4 to IPv6Transitioning IPv4 to IPv6
Transitioning IPv4 to IPv6
 
123
123123
123
 
Cisco CCNA EIGRP IPV6 Configuration
Cisco CCNA EIGRP IPV6 ConfigurationCisco CCNA EIGRP IPV6 Configuration
Cisco CCNA EIGRP IPV6 Configuration
 
A deep dive about VIP,HAIP, and SCAN
A deep dive about VIP,HAIP, and SCAN A deep dive about VIP,HAIP, and SCAN
A deep dive about VIP,HAIP, and SCAN
 
200 ccna questions
200 ccna questions200 ccna questions
200 ccna questions
 
Nat failover with dual isp on cisco router configuration explained with example
Nat failover with dual isp on cisco router configuration explained with exampleNat failover with dual isp on cisco router configuration explained with example
Nat failover with dual isp on cisco router configuration explained with example
 
Morethan200ccnaquesti 140420001832-phpapp02
Morethan200ccnaquesti 140420001832-phpapp02Morethan200ccnaquesti 140420001832-phpapp02
Morethan200ccnaquesti 140420001832-phpapp02
 
More than 200 CCNA Question Answer
More than 200 CCNA Question AnswerMore than 200 CCNA Question Answer
More than 200 CCNA Question Answer
 
Day 17.1 nat pat
Day 17.1 nat pat Day 17.1 nat pat
Day 17.1 nat pat
 
Ik
IkIk
Ik
 
Day 17.1 nat pat (2)
Day 17.1 nat pat  (2)Day 17.1 nat pat  (2)
Day 17.1 nat pat (2)
 
Nat 07
Nat 07Nat 07
Nat 07
 
Nat 03
Nat 03Nat 03
Nat 03
 
Nxll18 vpn (s2 s gre & dmvpn)
Nxll18 vpn (s2 s gre & dmvpn)Nxll18 vpn (s2 s gre & dmvpn)
Nxll18 vpn (s2 s gre & dmvpn)
 
Cisco CCNA OSPF IPV6 Configuration
Cisco CCNA OSPF IPV6 ConfigurationCisco CCNA OSPF IPV6 Configuration
Cisco CCNA OSPF IPV6 Configuration
 
Capacitacion 2018
Capacitacion 2018Capacitacion 2018
Capacitacion 2018
 
OpenStack Havana over IPv6
OpenStack Havana over IPv6OpenStack Havana over IPv6
OpenStack Havana over IPv6
 
Internet Technology Practical (Mumbai University) -2017
Internet Technology Practical  (Mumbai University) -2017Internet Technology Practical  (Mumbai University) -2017
Internet Technology Practical (Mumbai University) -2017
 

Dernier

Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 

Dernier (20)

Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 

ipv6 programming

  • 1. IPv6 Programming Eric 2012/06/29
  • 2. outline echo client echo server DNS conversions refine our app to support ipv6 and ipv4 special case
  • 3. ipv4 echo client int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); struct sockaddr_in serv_addr; memset((unsigned char *)&serv_addr, 0x00, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_port = htons(9999); inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr); connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
  • 4. ipv6 echo client int sock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP); struct sockaddr_in6 serv_addr; memset((unsigned char *)&serv_addr, 0x00, sizeof(serv_addr)); serv_addr.sin6_family = AF_INET6; serv_addr.sin6_port = htons(9999); inet_pton(AF_INET6, "::1", &serv_addr.sin6_addr); connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
  • 6. ipv4 echo server int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); struct sockaddr_in serv_addr; memset((unsigned char *)&serv_addr, 0x00, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_port = htons(9999); serv_addr.sin_addr.s_addr = INADDR_ANY; struct sockaddr_in client_addr; bind(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)); listen(sock, 20); socklen_t len = sizeof(client_addr); int conn = accept(sock, (struct sockaddr *)&client_addr, &len);
  • 7. ipv6 echo server int sock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP); struct sockaddr_in6 serv_addr; memset((unsigned char *)&serv_addr, 0x00, sizeof(serv_addr)); serv_addr.sin6_family = AF_INET6; serv_addr.sin6_port = htons(9999); serv_addr.sin6_addr = in6addr_any; const int on = 1; setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)); struct sockaddr_in6 client_addr; bind(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)); listen(sock, 20); socklen_t len = sizeof(client_addr); int conn = accept(sock, (struct sockaddr *)&client_addr, &len);
  • 8. ipv4 & ipv6 echo server let’s see echoServer2.c set up 2 socket for ipv4 and ipv6 independently. select is key point.
  • 9. DNS conversions please notice following functions: gethostbyname gethostbyaddr gethostbyname2 inet_aton, inet_ntoa let’s see hostent.c
  • 12. refine our app to support ipv6 and ipv4 grep -re “gethostby” * grep -re “inet_ntoa” * grep -re “inet_aton” * grep -re “AF_INET” * grep -re “sockaddr_in” *
  • 13. special case if our environment support ipv4 and ipv6, so server is simple ipv4 -> ipv4 socket ipv6 -> ipv6 socket const int on = 1; setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
  • 14. special case if our environment support ipv4 and ipv6, so client must consider priority of DNS conversions and retry connection.
  • 15. special case but...... if our environment is ipv4 only, we should use hints.ai_family = AF_INET on getaddrinfo. relatively, env is ipv6 only, please enable hints.ai_family = AF_INET6 on getaddrinfo.

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n