|
From: Per W. <pw...@ia...> - 2007-10-01 04:04:50
|
Please - this has nothing to do with winsock. I repeat - this has nothing
to do with winsock.
You get a request.
The request contains a path.
You translate that path to something on the local file system.
You open the translated file name.
You send back the contents of that file.
You either close the connection, or - if you and the client supports
keep-connect - wait for more requests on the same connection.
Have you started by printing out all HTTP header information you get from
the client for different types of links?
Have you spent time reading the HTTP protocol standard?
There is no magic web folder to create. It is the web server (your code,
not winsock or any other transport layer) that makes the translation from
request path to local file system path. This can be a translation to a
local directory tree, but that is not a requirement. All requests can be
hard-coded to external files or to internal functions that builds
pages/images on the fly.
Not only must you process the request and figure out the path - you must
also make sure that the web server only serves allowed files, i.e. that it
can't be used to walk all over your computer, if the request contains ..
or drive letters. But this too is your job - not something to do with
winsock, or the server running on a Windows machine.
/pwm
On Sun, 30 Sep 2007, angel dario wrote:
>
>
>
> From: sci...@ho...: pw...@ia...: RE: =
[Dev-C++] Anybody???Date: Sun, 30 Sep 2007 21:49:19 -0600
>
>
> none of those links works. either: http://ip/image.giforimage.gif doesn'=
t work. why?Because, i don't know how to make a www folder using winsock, s=
o i can drop images, html source and all that so that the web could be able=
torequest them successfully. look what i do so that the images can work on=
the server: This is just an example: (source code isn't real, is just a mo=
del) if( GET \ image.gif HTTP/1.1){ send(image.gif)} If i don't use thi=
s, when the browser tries to download the image form http://ip/images/the i=
mage fails. And this is the only output the browsers can send. If only the =
browser request for all of the imagesthen the server would work very fine. =
For example: if( GET \ image.gif HTTP/1.1){ send(image.gif)} if( GET \ =
image2.gif HTTP/1.1){ send(image2.gif)} if( GET \ image3.gif HTTP/1.1){=
send(image3.gif)} I really understand who HTTP works and how servers w=
ork. I just don't know how to make the www folder or the database or whatev=
er name is that folder called, so that i can drop files there for the reque=
sts. To give you an idea, i am building something like IIS.
>
> > Date: Mon, 1 Oct 2007 05:28:16 +0200> From: pw...@ia...> To: s=
cie...@ho...> CC: dev...@li...> Sub=
ject: Re: [Dev-C++] Anybody???> > Have you read up on the HTTP protocol?> >=
If your server claim that it users a modern version of the HTTP protocol,>=
then most web browsers will issue several requests on the same connect. If=
> you claim that the server only supports standard 1.0, then the browsers> =
will have to make new connects for each request.> > There are no magic invo=
lved with winsock - your problems doesn't have> anything to do with winsock=
, but with understanding the HTTP protocol, and> what a web server is expec=
ted to do.> > A client should not know anything about c:\Dev-Cpp\images - y=
our web> server should have a defined root directory, and should figure out=
all> paths either based on that root directory or on individual path> tran=
slations.> > You can also affect what requests the web browser makes by swi=
tching> between absolute, relative and fully qualified image names.> > Some=
possible links you might have in the served document:> <a href=3D"http://<=
ip>/images/image1.gif">> <a href=3D"/images/image1.gif">> <a href=3D"images=
/image1.gif">> > If you specify a relative path, then the client (the web b=
rowser) must> perform it's request relative to the main document. With an a=
bsolute path,> it is enough to use the same connect - or a new connect to t=
he same> server. With a fully qualified URL, the web browser may connect to=
any web> server to retrieve an image.> > /pwm> > On Sun, 30 Sep 2007, ange=
l dario wrote:> > > Have anybody build a server using winsock2 and C++?> >>=
> YES?> > Have you use port 80 to send html data?> >> > YES?> > What did y=
ou used when the HTML code that you send to the browser had more than 1 pic=
tured?> >> > What did you do when the browser tried to connect to http://yo=
uripaddress/image.gif ?????> >> > .........................................=
=2E....................................> >> > I tried to solve this problem=
doing this:> >> > I waited for the browser to ask for the image:> >> > GET=
/image.gif HTTP/1.1> >> > Then i send it, and it work...> >> > BUT....> >>=
> Sometimes the browser just request for only 1 image, and the rest of the=
images,> > the browser tries to download them, using the path http://youri=
paddress/> >> > I still can't figure out how browsers can download some dat=
a from servers without sending any request.....> >> > Is there a way, USING=
WINSOCK2, to let the browser know that http://youripaddress/ is just, C:\D=
ev-Cpp\images\?> >> > A source code will help better than a plain answer.> =
>> > _________________________________________________________________> > C=
onnect to the next generation of MSN Messenger > > http://imagine-msn.com/m=
essenger/launch80/default.aspx?locale=3Den-us&source=3Dwlmailtagline>
>
> Connect to the next generation of MSN Messenger Get it now!
> _________________________________________________________________
> Discover the new Windows Vista
> http://search.msn.com/results.aspx?q=3Dwindows+vista&mkt=3Den-US&form=3DQ=
BRE
|