Answers for "get sockets check if ipaddress is hosting python"

6

python socket get client ip address

## importing socket module
import socket
## getting the hostname by socket.gethostname() method
hostname = socket.gethostname()
## getting the IP address using socket.gethostbyname() method
ip_address = socket.gethostbyname(hostname)
## printing the hostname and ip_address
print(f"Hostname: {hostname}")
print(f"IP Address: {ip_address}")
Posted by: Guest on January-23-2021
0

socket get hostname of connection python

self.server.getsockname()
#('127.0.0.1', 8088)
Posted by: Guest on March-16-2022

Python Answers by Framework

Browse Popular Code Answers by Language