Answers for "print ip of client connecting to server sockets() python3"

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

python socket get client ip

# If you are connected to the client socket you can get its address
client_socket.getpeername()
# Expected return value is a Tuple (ip, port)

# You can also get your own socket address
client_socket.getsockname()
# Expected return value is a Tuple (ip, port)
Posted by: Guest on September-04-2021

Code answers related to "print ip of client connecting to server sockets() python3"

Python Answers by Framework

Browse Popular Code Answers by Language