#!/usr/bin/python3 # -*- coding: utf-8 -*- import socket # Create a socket object (defaults to AF_INET and SOCK_STREAM) s = socket.socket() # Get local name, 127.0.0.1 and localhost work host = socket.gethostname() print(host) # Reserve a port for your service. port = 12345 # host not needed, could be '' s.connect((host, port)) print(s.recv(1024).decode()) # Close the socket when done s.close