Project

General

Profile

Get server address

Added by prest1ge c0ding about 8 years ago

Hello together.

Is it possible to get the server's address where the application is running on?

I mean the http-address from:

./myApp ---http-address ---http-port

I found Wt::Http::Client::URL Struct Reference from: [[[http://www.webtoolkit.eu/wt/doc/reference/html/structWt_1_1Http_1_1Client_1_1URL.html#a5abe971812861a7c0869fea2917b6d0c]]]

But how to get this informations?

Debian 8 Jessie amd64 Linux-4.3

witty 3.3.4


Replies (1)

RE: Get server address - Added by Louis Hoefler about 8 years ago

There is a logic question i ask myselve.

One Server can bind to multiple adresses. Therefore if you want to bind your server to a specific adress, you know your adress before you start your server.

So either you can hardcode the adress you want to test against into your code, our you have to get the adress which the client requests.

This is done with a Request http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1Http_1_1Request.html

You can either read out the complete requested url, or you could read out HTML headers.

There are related examples in featue/socketnotifier

Or maybe blog/BlogRSSFeed.c with request.serverName()

Greeting, Louis

    (1-1/1)