Re: Accessing web with a C program
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Fri, 09 Feb 2007 15:49:21 -0800
rlb@xxxxxxxxxxxxxxxxxxxxxx (Richard Bos) writes:
"Lew Pitcher" <lpitcher@xxxxxxxxxxxx> wrote:
On Feb 8, 3:40 pm, Christopher Benson-Manica
<a...@xxxxxxxxxxxxxxxxxxx> wrote:
Lew Pitcher <lpitc...@xxxxxxxxxxxx> wrote:
You /should/ be able to
FILE *web = fopen("http://google.com/","r");
and have a valid read connection to the named web page.
Should? I'm curious, what argues for this behavior? I certainly
wouldn't expect it from fopen() regardless of whether it was commonly
implemented or not.
What sort of behaviour would you expect from
FILE *somefile = fopen("C:\\ABC\\DEF\\GHI.J","r");
or
FILE *somefile = fopen("DDNAME:SYSIN,"r");
or
FILE *somefile = fopen("/a/b/c.d","r");
I'd expect it to open a local file.
How do you know that "/a/b/c.d" is the name of a local file? It could
well be stored on some server somewhere and accessed via NFS or some
other protocol.
This is very different from opening a URL, because that involves making
a connection to a random machine on the 'net, and possibly getting the
user to enter dialing passwords and all.
It's not obvious that fopen() should support the NFS protocol but not
the HTTP protocol. There is a difference in that an HTTP name (a URL)
specifally names the remote server -- but some systems, including VMS,
have file names that do the same thing but are expected to be treated
as ordinary files.
It's also possible, on some operating systems, to create a filesystem
that maps URLs to what appear to be local file names. On such a
system, fopen("http://google.com", "r") would invoke code in the
filesystem driver that would access google.com using the HTTP
protocol, but that would be invisible to the program that calls
fopen(). Given this capability letting fopen() accept URLs directly
is just a matter of doing the net access at a different level.
Of course, you have to draw the line somewhere. The usual practice is
*not* to treat URLs as file names. In my opinion, that's not a bad
place to draw the line, but I don't see any strong arguments for or
against drawing it somewhere else.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- Follow-Ups:
- Re: Accessing web with a C program
- From: Richard Bos
- Re: Accessing web with a C program
- References:
- Accessing web with a C program
- From: Neo
- Re: Accessing web with a C program
- From: Lew Pitcher
- Re: Accessing web with a C program
- From: Christopher Benson-Manica
- Re: Accessing web with a C program
- From: Lew Pitcher
- Re: Accessing web with a C program
- From: Richard Bos
- Accessing web with a C program
- Prev by Date: Re: Undefined Behavior of printf
- Next by Date: Re: IS this a proper way of freeing memory with free()
- Previous by thread: Re: Accessing web with a C program
- Next by thread: Re: Accessing web with a C program
- Index(es):
Relevant Pages
|