Sockets

Python Sockets

  • Connects one node to another node

#!/bin/python3

# Import socket module 
import socket 

# Define variables
HOST = '127.0.0.1'
PORT = 7777

# AF_INET is IPv4 and SOCK_STREAM is a port 
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

s.connect((HOST,PORT))

Last updated