Malte Forkel <malte.for...@berlin.de> writes: > I have a Python application that communicates with a server via > telnet. Host and port of the server are supplied by the user when the > application is started. > > How can I determine from within the application whether the server's > host actually is the local host? (In that case I could implement an > operation not available in the telnet-based protocol by directly > accessing the local filesystem.)
On Unix, this is up to the person invoking the program: the “sockets facility allows for a host-local connection to appear as though it's going over a network. <URL:https://en.wikipedia.org/wiki/Localhost> <URL:https://en.wikipedia.org/wiki/Unix_domain_socket> In other words: Your program shouldn't go snooping around to second-guess the connection type; if the user asked for a TCP/IP connection, that's what they should get. If they want to take advantage of a local connection, they can use a Unix domain socket. -- \ “I wrote a song, but I can't read music so I don't know what it | `\ is. Every once in a while I'll be listening to the radio and I | _o__) say, ‘I think I might have written that.’” —Steven Wright | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list