|
From: angel d. <sci...@ho...> - 2007-09-21 04:47:55
|
=20
So far, thanks to all of you who help me with the HTTP winsock2 code, i hav=
e enough info now to start building my server.
Everything seems to be working very good but there is only one problem:
=20
The server that i created works like this:
I use ifstream() to get the frontgage.html and put it into a char *buffer v=
ariable.
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 co=
ntains the html code.
Client:
Clients opens a webpage and types 12.145.32.156/frontpage.html on the addre=
ss 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: =20
<a href=3D"www.google.com">Index</a>
=20
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 th=
e browser displays cannot find server.
Also: if i try to load a picture like this:
<img src=3D"image.gif" name=3D"image" alt=3D"image" bo=
rder=3D"1" align=3D"middle">
The browser tries to download the picture from 12.145.32.156/image.gif whic=
h doesn't exist.
So the question is, how do i tell the browser where to find the things , li=
ke the image, or where to go, like the link????
Or how to upload the image so that when the frontpage.html displays, it dis=
play the image in it.
=20
I've been thinking about this for a while, and think i have a logic solutio=
n for the image thing:
=20
If i upload the image and call it image.gif, then when i link it through ht=
ml, 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.gi=
f is.
Is there a way to manipulate the ip (12.145.32.156) as a folder so that i c=
an 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??
=20
_________________________________________________________________
Capture your memories in an online journal!
http://www.reallivemoms.com?ocid=3DTXT_TAGHM&loc=3Dus=
|