Solved

Internet Host Name

Posted on 2000-04-19
9
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 1

Author Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

691 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