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:

  1. your assumption 'every user connection opens connection @ unique port' wrong. users using same port connect.
  2. 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:

https://docs.djangoproject.com/en/1.8/topics/http/sessions/


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -