python - How do I get the client port number in a Django project? -
i using django build web server, other people connect me clients. need know clients' port number distinguish them. if browser opens 2 'tabs' of same link, i.e. 2 pages same link, have distinguish them.
although know can use request.meta['remote_addr'] client's ip in django view function, realy not enough me.
then studied tcp/ip basics , know in tcp/ip layer, every ip packet has ip header contains client's port number. how can access in django?
additional info:
- i'm using python 2.6 , django 1.4
- i know every tab of browser allocated random unique port access django web page port. -- see link 'the web server opens port 80, browser has different, randomly-assigned port.' need distinguish them. intuitive thoughts use port number in ip packet. if have other suggestion, welcome.
- i have found the similar question here, not using apache now. , may hard me config maybe causing other more complex questions. might make simple question complex.
- your assumption 'every user connection opens connection @ unique port' wrong. users using same port connect.
- to distinguish users django (and every other frameworks) using sessions. every user gets cookie unique session id, , cookie passed server on every connection, application can distinguish users. if cookies turned off, session id passed get-parameter.
here documentation on sessions:
Comments
Post a Comment