binding to localhost - slightly OT
Alex Martelli
aleaxit at yahoo.com
Wed Sep 22 05:51:31 EDT 2004
More information about the Python-list mailing list
Wed Sep 22 05:51:31 EDT 2004
- Previous message (by thread): Somthing strange with list as default argument
- Next message (by thread): binding to localhost - slightly OT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Ajay <abra9823 at mail.usyd.edu.au> wrote: > I am making the following call on my PDA which has WLAN connectivity > >>>import socket > >>>socket.gethostbyname(socket.gethostname()) > this prints 127.0.0.1 > the PDA has an assigned IP address. > so if i go > UDPserversocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) > UDPserversocket.bind((socket.gethostname(), LOCAL_SERVER_PORT)) > > this binds to the localhost instead of the assigned IP address. how can i > get it to bind to the assigned IP? i dont want to explicitly enter the IP > address into the bind call, since the IP may change. If you .bind to a specific address, you are only going to be reachable from that address -- is that what you're trying to do? If so, then any of the addresses for your host should be just as good (or just as bad). I suspect that what you're TRYING to do is bind(socket.INADDR_ANY, ... so that OTHER machines can send you datagrams... I believe a '' would also work as the first argument to bind, instead of INADDR_ANY. Alex
- Previous message (by thread): Somthing strange with list as default argument
- Next message (by thread): binding to localhost - slightly OT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list