Solved

Internet Host Name

Posted on 2000-04-19
9
228 Views
Last Modified: 2010-04-02
i'm writing a prog in which i assume
that a name of all the internet servers
is build like that:
http://name1.name2.name3
example:
http://www.google.com
so i would like to know it right

if not then if i have a request from the broweser how can i get the host name from it

example:
GET http://www.google.com/home_pg.gif HTTP 1.0

the host name is www.google.com

thanks
0
Comment
Question by:ntdragon
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 8

Expert Comment

by:Christoffer Swanström
ID: 2730606
In general, you can not assume that all server names consist of only three parts. Although most of them do, there also a lot of servers with 2,4,5... parts in their name.

I didn't really understand your question, could you define it a bit better?
0
 
LVL 5

Expert Comment

by:proskig
ID: 2730641
I agree with tosse, e.g. some have .co.uk instead of .com
0
 
LVL 86

Expert Comment

by:jkr
ID: 2730806
But you can assume that the host name is enclosed between '//' and the next '/'...
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 1

Author Comment

by:ntdragon
ID: 2732309
i would like to know
how can i get the host name from the broweser request

when broweser requests a file the request look like:

GET http://www.goole.com/home_page.gif HTTP 1.0 header...

i need to get the host name from these request <or any other request like it>

can i do what jkr said
i mean is the host name is writen between // and / <every host name>

my goal is to write a func that will get the host name from the request
<it shouldn't depend on the host name niether on the request what i mean is it should work for every request the broweser might send>
0
 
LVL 86

Accepted Solution

by:
jkr earned 40 total points
ID: 2732346
>>can i do what jkr said
>>i mean is the host name is writen
>>between // and /

There is one exceptions, i.e. http servers that require user authentication - in this case, it'd be sth. like

http://user@server.subnet.subdomain.ext/

So the approach would be:

- isolate the string between '//' and the 1st '/' (or the end of the URL, if no path is given)
- look if there's an '@' - if so, the server name starts there...
0
 
LVL 1

Author Comment

by:ntdragon
ID: 2732381
i"ll write my funcand try it then i"ll get back
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2732456
There will undoubtedly be a RFC for this, index of those at http://www.internic.net/ds/rfc-index.htm
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2732488
0
 
LVL 1

Author Comment

by:ntdragon
ID: 2740660
thanks you all
my func work great with your help
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question