Parameters & Returns
Parameters
This function takes no parameters.
Returns
Quick Summary
Returns the local machine's IP address.
Takes no parameters.
Returns the local IP in dotted notation, or "127.0.0.1" if lookup fails (String).
Technical Exegesis...
Retrieves the first IP address of the local machine by querying the hostname and resolving it via DNS. Returns the IP in dotted notation (e.g., "192.168.1.100"), or "127.0.0.1" if the lookup fails.
Uses gethostname to get the local hostname, then gethostbyname to resolve it, and inet_ntoa to convert to string. Returns the first IP from the address list. Returns loopback address (127.0.0.1) on error. Useful for servers that need to report their IP address.