updated client anserver for week02 easy

This commit is contained in:
2024-11-07 21:49:47 +09:00
parent 2858c522ef
commit 1b8c1f4526
4 changed files with 216 additions and 0 deletions

View File

@ -0,0 +1,17 @@
import netifaces
def print_ethernet_interfaces():
"""Prints all Ethernet interfaces and their IP addresses."""
interfaces = netifaces.interfaces()
for interface in interfaces:
addresses = netifaces.ifaddresses(interface)
if netifaces.AF_INET in addresses:
for addr in addresses[netifaces.AF_INET]:
ip_address = addr["addr"]
print(f"Interface: {interface}, IP Address: {ip_address}")
if __name__ == "__main__":
print_ethernet_interfaces()