socket program get remote host name python code example Example: get hostname socket socket.gethostbyname(socket.gethostname())