-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvidu-socket.py
More file actions
22 lines (21 loc) · 803 Bytes
/
vidu-socket.py
File metadata and controls
22 lines (21 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
#
import socket
###Tra ve domain name cua di chi 8.8.8.8 (Fully Qualified Domain Name)
print "FQDN 8.8.8.8: ", socket.getfqdn("8.8.8.8")
print ''
###Kiem tra IP Address may chu pythonvietnam.info
print "Dia chi IP cua PTVN: ", socket.gethostbyname_ex("pythonvietnam.info")
print "Dia chi IP cua PTVN: ", socket.gethostbyname("pythonvietnam.info")
print ''
print "Ten may cua ban: ", socket.gethostname()
remoteServer = raw_input("Nhap ten website: ")
remoteServerIP = socket.gethostbyname(remoteServer)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print sock.connect_ex((remoteServer, 80))
# name = raw_input('Nhap ten web: ')
# try:
# host = socket.gethostbyname(name)
# print host
# except socket.gaierror:
# print "Khong tim thay trang web: ", name