From: Per W. <pw...@ia...> - 2007-09-21 06:32:33
|
A http link should be written http://server/page if you want to access a different server. You must teach your server to correctly parse the http request and decide if it is an absolute or relative path, and you must then map that path against a directory on the server disk, or let the server know what data to auto-build depending on the path. Have you read about what http fields a http server is expected to unserstand and to emit when doing it's work? /pwm On Thu, 20 Sep 2007, angel dario wrote: > > So far, thanks to all of you who help me with the HTTP winsock2 code, i have enough info now to start building my server. > Everything seems to be working very good but there is only one problem: > > The server that i created works like this: > > I use ifstream() to get the frontgage.html and put it into a char *buffer variable. > I host on port[80] and listen(), waiting for any client to be connected. > when the client connects, i use send() function to send the buffer which contains the html code. > Client: > > > Clients opens a webpage and types 12.145.32.156/frontpage.html on the address bar. > > Then the pages (which is buffer itself) displays successfully. > Here is the problem: > > > Whenever i create a hypertext(link) in the html code, for example: > <a href="www.google.com">Index</a> > > and i pass it to the buffer variable, (first using ifstream). > > The browser goes to 12.145.32.156/www.google.com which doesn't exist, so the browser displays cannot find server. > Also: if i try to load a picture like this: > <img src="image.gif" name="image" alt="image" border="1" align="middle"> > > The browser tries to download the picture from 12.145.32.156/image.gif which doesn't exist. > So the question is, how do i tell the browser where to find the things , like the image, or where to go, like the link???? > Or how to upload the image so that when the frontpage.html displays, it display the image in it. > > I've been thinking about this for a while, and think i have a logic solution for the image thing: > > > > If i upload the image and call it image.gif, then when i link it through html, then the browser will find it. > > but problem is that the browser is trying to connect using the path: 12.145.32.156/ which is another place (no idea where) which is not where image.gif is. > Is there a way to manipulate the ip (12.145.32.156) as a folder so that i can drop images and icons, so that when the client connects to the > server, the browser gets the images and icons from the http://12.145.32.156/ path?? > > _________________________________________________________________ > Capture your memories in an online journal! > http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us |