Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HTTP Headers: Remote Address  RSS feed

 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As mentioned in another post, I'm writing a little HTTP server and trying to understand all the headers. I'd like to capture the remote address but I don't see that header at all. I do get a couple that appear to be masked out or something - name & value are all X, like: XXXXX=XXXXXXXXX
Here's a typical set of log entries for this thing:

Hmmm, that one had no Xs. Anyhow, am I missing something that would get me the remote address or remote host or some of those? This is an IE5 client, local host server. Am I being dumb ... is that just not remote enough to generate the header?
[ October 10, 2003: Message edited by: Stan James ]
 
Lewin Chan
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need the remote address?
You won't need it to send data back to client, just send it on the currently open socket.
i.e. your server would respond with

after doing a getOutputStream() on the Socket that you've accepted on.
If you don't want to wade through RFC2068 and others.. (you should, you know, give that you're writing a http server ) then try http://www.jmarshall.com/easy/http/
(incidentally, you know the remote address by querying the socket object directly

which gives you the remote address that connected to you...
brgds
Lewin
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I finally figured out I could get it from the socket. I'm writing my own little web server, and I wanted client IP address for an audit log. I have a captive audience inside the firewall at work so I can find out who an address belongs to if I ever care.
I'm also using it as key to a hashmap of sessions. It behaves a little strangely compared to other servers: multiple client programs on the same PC share the session, and the session survives shutting down the browser and restarting it. Maybe I'll go to a generated session id and cookies later.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!