• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

Internet Host Name

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
ntdragon
Asked:
ntdragon
  • 3
  • 2
  • 2
  • +2
1 Solution
 
Christoffer SwanströmPartnerCommented:
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
 
proskigCommented:
I agree with tosse, e.g. some have .co.uk instead of .com
0
 
jkrCommented:
But you can assume that the host name is enclosed between '//' and the next '/'...
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
ntdragonAuthor Commented:
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
 
jkrCommented:
>>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
 
ntdragonAuthor Commented:
i"ll write my funcand try it then i"ll get back
0
 
KangaRooCommented:
There will undoubtedly be a RFC for this, index of those at http://www.internic.net/ds/rfc-index.htm
0
 
ntdragonAuthor Commented:
thanks you all
my func work great with your help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now