"bruce" <bedoug...@earthlink.net> writes: [a top-posted monstrosity]
> so the question really starts to look like: > > -what's the default listening address for my app (insert nic)? > -what's the default sending address for my app (insert nic)? > -what's the default listening address for my server? > -what's the default sending address for my server? > -what's the default listening address for my (insert nic)? > -what's the default sending address for my (insert nic)? > > any other possibilities?? A TCP server will typically listen on: * all addresses (INADDR_ANY), * localhost (INADDR_LOOPBACK), or * an address explicitly provided by the administrator. (There's a fourth possibility: it might listen separately on each network interface, but that's quite unusual.) Anyway, it ought to know which of these it's doing. When a client connects, it gets the client's address from accept(2) or getpeername(2) and its local address from getsockname(2). A TCP client can find out its address using getsockname(2) after connect(2). So that's easy too. But TCP isn't very interesting here, because both ends know the others' address by the time the connection is established, so there's no point in explicitly sending them. (I suppose you could use explicit addresses to detect NAT routers which aren't doing protocol-specific bodging.) UDP is much messier, since a single socket could be acting as a client or server, or in a strictly symmetrical arrangement. Even so, it's usually much better to have the hosts concerned dredge out their peers' addresses from the packets they receive rather than send them about explicitly. Which is why I'm puzzled as to what this information is actually for. -- [mdw] -- http://mail.python.org/mailman/listinfo/python-list