March 2019
Beginner
490 pages
12h 40m
English
First, we define the necessary variables for the connection, that is, the IP address for localhost in IPv6 format and the maximum number of connections from clients:
IPV6_ADDRESS = '::1'# Up to 5 clients can connectmaxConnections = 5
Next, since we have the necessary data, we create the server. It is a socket-type object that is listening in a specific port using IPv6 and TCP/IP:
# Creating the server with ipv6 support# socket.AF_INET6 to indicate that we will use Ipv6# socket.SOCK_STREAM to use TCP/IPserver_socket = socket.socket(socket.AF_INET6,socket.SOCK_STREAM)dataConection = (host,port)server_socket.bind(dataConection)
Our socket is already created. Now we must accept connections from it:
print("Waiting connections ...Read now
Unlock full access