Socket programming...

Gethostbyname() and gethostbyaddr()

import socket

def print_machin_info():
    host_name = socket.gethostname()
    ip_address = socket.gethostname(host_name)
    print ("Host name of your computer: %s", host_name)
    print("Your computer ip address: %s", ip_address)

print_machin_info()


Connecting servers:

import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
r = s.connect(("www.mcmillan-inc.com", 80))
print(r)


Getting input from user and given the output:

import socket
def python_info():
    name = input("Enter the website:")
   
    host = socket.gethostbyname(name)
    print ("Ip address of  is :", host)
   

python_info()



  


 

Comments

Popular Posts