Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> from socket import getaddrinfo
- >>> getaddrinfo(None, 'smtp', 0, socket.SOCK_STREAM, 0, socket.AI_PASSIVE)
- Traceback (most recent call last):
- File "<input>", line 1, in <module>
- NameError: name 'socket' is not defined
- >>> import socket
- >>> getaddrinfo(None, 'smtp', 0, socket.SOCK_STREAM, 0, socket.AI_PASSIVE)
- [(2, 1, 6, '', ('0.0.0.0', 25)), (10, 1, 6, '', ('::', 25, 0, 0))]
- >>> getaddrinfo(None, 53, 0, socket.SOCK_DGRAM, 0, socket.AI_PASSIVE)
- [(2, 2, 17, '', ('0.0.0.0', 53)), (10, 2, 17, '', ('::', 53, 0, 0))]
- >>>
- >>> getaddrinfo('127.0.0.1', 'smtp', 0, socket.SOCK_STREAM, 0)
- [(2, 1, 6, '', ('127.0.0.1', 25))]
- >>> getaddrinfo('localhost', 'smtp', 0, socket.SOCK_STREAM, 0)
- [(10, 1, 6, '', ('::1', 25, 0, 0)), (2, 1, 6, '', ('127.0.0.1', 25))]
- >>>
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++
- >>> getaddrinfo('ftp.kernel.org', 'ftp', 0, socket.SOCK_STREAM, 0, socket.AI_ADDRCONFIG | socket.AI_V4MAPPED)
- [(2, 1, 6, '', ('198.145.20.140', 21)), (2, 1, 6, '', ('199.204.44.194', 21)), (2, 1, 6, '', ('149.20.4.69', 21))]
- >>> getaddrinfo('iana.org', 'www', 0, socket.SOCK_STREAM, 0, socket.AI_ADDRCONFIG | socket.AI_V4MAPPED)
- [(2, 1, 6, '', ('192.0.43.8', 80)), (10, 1, 6, '', ('2001:500:88:200::8', 80, 0, 0))]
- >>> getaddrinfo('iana.org', 'www', 0, socket.SOCK_STREAM, 0)
- [(2, 1, 6, '', ('192.0.43.8', 80)), (10, 1, 6, '', ('2001:500:88:200::8', 80, 0, 0))]
- >>> getaddrinfo('iana.org', 'www', 0, socket.SOCK_STREAM, 0, socket.AI_ADDRCONFIG | socket.AI_V4MAPPED | socket.AI_CANONNAME)
- [(2, 1, 6, 'iana.org', ('192.0.43.8', 80)), (10, 1, 6, '', ('2001:500:88:200::8', 80, 0, 0))]
- >>> mysock = old_sock.accept()
- Traceback (most recent call last):
- File "<input>", line 1, in <module>
- NameError: name 'old_sock' is not defined
- >>> socket.gethostname()
- 'nsa'
- >>> socket.getfqdn()
- 'nsa.fuckyou.mil'
- >>> socket.gethostbyname('cern.ch')
- '137.138.144.169'
- >>> socket.gethostbyaddr('137.138.144.169')
- ('webr8.cern.ch', [], ['137.138.144.169'])
- >>> socket.getprotobyname('UDP')
- 17
- >>> socket.getservbyname('www')
- 80
- >>> socket.getservbyport(80)
- 'http'
- >>> socket.gethostbyname(socket.getfqdn())
- '137.138.144.169'
- >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement