PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, October 21, 2022

[FIXED] How to implement ipv6 in python?

 October 21, 2022     sockets     No comments   

Issue

I want to connect my program with ipv6 and not ipv4 My code is:

import socket
import threading

HEADER = 128
PORT = someport
#SERVER = socket.gethostbyname(socket.gethostname())
SERVER = 'someip'
ADDR = (SERVER, PORT)
FORMAT = "utf-8"
DISCONNECTED_MESSAGE = "!DISCONNECTED"

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(ADDR)

I already know how to do it with ipv4, but not with ipv6.


Solution

There is actually a very simple solution to that You could add:

server = socket.socket(socket.AF_INET**6**, socket.SOCK_STREAM)

and then put the ipv6 on your server variable



Answered By - yoyopi768 yoyopi768
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing