Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /tyvekzhang_fastlib /fastlib /utils /ip_util.py
| import socket | |
| def get_real_ip(): | |
| """ | |
| Get the real IP address of the local machine. | |
| This function attempts to determine the real (non-localhost) IP address | |
| of the local machine by creating a UDP connection to a public DNS server | |
| (8.8.8.8) and then checking which local IP address was used for this connection. | |
| Returns: | |
| str: The real IP address of the local machine if successful, | |
| otherwise the loopback address '127.0.0.1'. | |
| """ | |
| try: | |
| s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
| s.connect(("8.8.8.8", 80)) | |
| ip = s.getsockname()[0] | |
| s.close() | |
| return ip | |
| except Exception: | |
| return "127.0.0.1" | |
Xet Storage Details
- Size:
- 702 Bytes
- Xet hash:
- 5d3965fdfda2de58949319607618b9f37e5137307a18461a5fabea2dc26f92c4
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.