Why not networking support?

H

H.A. Sujith

Why should it?
What's wrong with the current standards?
Why must C compiler developers implement and distribute
a standard library for networking facilities?

The stdio library tries to provide a platform independent I/O library.
Twenty years ago networking may not have been as important or
as standardized as today. But TCP/IP has become the accepted standard and
networking has become a very important part in computing -- it has
become a part of what we call I/O.

The concept of sockets fits nicely with C's system of streams. It is sad
that we cant use the nice funtions of the stdio library for networking.
(Of course, we can manually do stuff like changing file descriptors but
things like that are prone to errors.) A consistent nertworking interface
would not only make applications more portable, it would also make more
applications portable.

Although most use of networking is done using high-level protocols
a standard network interface would still be useful. For example it would
make easier the development of platform independent libraries for high-level
protocols like HTTP.
 
D

Dan Pop

In said:
What does that mean to an 8-bit microcontroller with 128 bytes of RAM and
8kB of ROM? C has been ported to all sorts of hardware, many that simply
could not easily fit even a simple TCP/IP stack. No, C should not be
burdened with networking.

Bogus argument: does your implementation for the 8-bit microcontroller
with 128 bytes of RAM and 8kB of ROM come with a full implementation
of the standard C library? If the answer is no, would it matter if the
standard C library also included TCP/IP support?

Dan
 
D

Dan Pop

In said:
Humm, file access wouldn't make much sense on such systems either..
Anyway original poster should rather turn to the posix specifications.

The original POSIX standard knows about TCP/IP as much as the C standard.

Dan
 
D

Dan Pop

In said:
Me too, I think because then someone would ask, "Why not DeviceNET" and
then we'd add that to C and next thing you know, C would only be able to
run on hosted implementations.

Freestanding implementations need not provide *any* of the standard C
library, so I fail to see your point. You were not thinking about TCP/IP
support in the C syntax, right?

Dan
 
J

Joona I Palaste

Freestanding implementations need not provide *any* of the standard C
library, so I fail to see your point. You were not thinking about TCP/IP
support in the C syntax, right?

I don't think he was. We don't have STDIO support in the C syntax
either, have we?
 
B

Ben Pfaff

Mark A. Odell said:
What does that mean to an 8-bit microcontroller with 128 bytes of RAM and
8kB of ROM?

You are trying to say that there is an 8-bit microcontroller with
128 bytes of RAM, 8 kB of ROM, and a *hosted* implementation of
C? That'd be a sight to see.
 
D

Dan Pop

In said:
Something like the above could be done without any
change at all to Standard C. The implementation, not the
Standard, defines how file name strings are formatted and
what they mean, and nothing's preventing an implementation
from recognizing "tcp:127.0.0.1:9" as the designator for
a socket. (Or for a tuna salad sandwich, for that matter.)

But, if it's not required by the standard, you have no guarantee that
an implementation supports it all, so you cannot use it in portable code.

So, you can rely on fopen() for opening a file, if the user provides a
proper file name, but you can't rely on fopen() for opening a network
connection, no matter what the user does.

Dan
 
D

Dan Pop

In said:
Accepted wisdom aside, why /couldn't/ C (in a future incarnation) define
a 'networking' interface in the same flavour as it now provides a file
access interface?

The most likely answer would be: lack of existing practice. So, if some
popular implementor does it, there are chances for it to become a
standard feature. Until then, we're in the good old "the egg and
the hen" deadlock ;-)

Dan
 
L

Lew Pitcher

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dan said:
But, if it's not required by the standard, you have no guarantee that
an implementation supports it all, so you cannot use it in portable code.

But, then again, when passed to fopen() as the filename parameter, the
string "c:\\windows\\system32\\etc\\services" isn't required by the
standard either, nor is "/etc/services", or even "DD:SYSIN". But, this
lack of standardization doesn't prevent the use of fopen() in portable code.

If you are willing to decry the interpretation of the fopen() 'filename'
"tcp:127.0.0.1:9" as not being required by the standard, then you
probably should also decry "/etc/services" (or for that matter, just
"services") as well.
So, you can rely on fopen() for opening a file,

Ahh, but what is a "file"? AFAICT, C only has two requirements for a file:
1) that it can be manipulated by the f*() functions (fopen(), fread(),
etc.), and
2) the data retrieved from or written to it must be of an integral type,
or storable in an array of char.

I don't believe that the C standard dictates the storage media for a
file, nor it's organization wrt other files. I dont believe that the
standard even requires that files follow a particular naming convention.
And I don't see how network data fails to satisfy the two requirements,
when manipulated by the f*() functions.
if the user provides a
proper file name, but you can't rely on fopen() for opening a network
connection, no matter what the user does.

But, what dictates a "proper file name"? Is "DD:SYSIN" guaranteed to
exist /as the name of a file/? (I can assure you that, on the platform
from which that example comes, "DD:SYSIN" does /not/ exist as the name
of a file.) Or, how about "LPT:"? Is there always a /file/ associated
with that name? (Again, no, when you refer to the specific platform).

The point is that the C standard does not dictate the meaning of the
name given to the f*() functions, just like it doesn't dictate the
meaning of the string given to system(). All the standard /does/ require
is that the named resource /behave/ as a file. If "tcp:127.0.0.1:9"
behaves as a file, then it doesn't matter if the /implementation/
implements it as a file or as a network connection.

So, with this approach, networking can be fit within the confines of the
C standard /just like file I/O/, with the same implementation-dependant
caveats as file I/O has.

Lest you get the wrong idea, I proposed the "tcp:127.0.0.1:9" behaviour
as an illustration of why an explicit network api is not needed in C.
I doubt that ISO C will include an explicit networking api, /because/
generic networking can be handled with the current file I/O api with the
same sort of platform and implementation-specific work "under the
covers" that ISO C standard file I/O currently requires.

- --

Lew Pitcher, IT Consultant, Enterprise Application Architecture
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFA9WbXagVFX4UWr64RAmZ4AJ9E6oVzWE10ZalXj4gykIDnuYjqewCg3V/J
D+lsMufjH48ELaPN2Q4AsNU=
=ZPS7
-----END PGP SIGNATURE-----
 
L

Lew Pitcher

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dan said:
In <[email protected]> Lew Pitcher


The most likely answer would be: lack of existing practice. So, if some
popular implementor does it, there are chances for it to become a
standard feature. Until then, we're in the good old "the egg and
the hen" deadlock ;-)

That's an answer I can live with :)

Until some C implementation actually /implements/ this behaviour, we
won't ever /see/ this behaviour.

Perhaps we can convince PJP that Dinkumware /needs/ to implement
networking within their stdio library <vbg>

- --

Lew Pitcher, IT Consultant, Enterprise Application Architecture
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFA9WdeagVFX4UWr64RAlwbAJ0eTfpv6pxmWKxQHTLDweNQTdbMmACgv3Lt
UYMI3MdTiGE8Qmh3+2TwTCo=
=UOUz
-----END PGP SIGNATURE-----
 
D

Dan Pop

Probably because it wouldn't be useful (which AFAICT was Dan's original
point).

My point was directed towards the OP's request for TCP/IP support in
standard C. It doesn't apply to a generic networking interface, as
suggested by Lew.
If it only does TCP/IP, it's useless to people who want to use
other protocols, and if it only does the kind of "raw" communications
provided by the *nixy accept/bind/connect/listen paradigm, then, well,
people who program on those platforms *already* have that functionality
available, and don't need standard C to provide it.
And raw communications aren't generally useful anyway. What the
client programmer wants is a simple interface, like the "extended
fopen" you describe below. And that interface would have to imply
some kind of really-high-level protocol like, I dunno, HTTP or FTP
or something. Or one of the myriad P2P protocols about which I know
*really* nothing.
In short: Raw communications are too low-level to be an improvement
over OS calls, and high-level communications are too narrowly useful.

So, go for the intermediate level provided by TCP/IP: TCP or UDP level
connections instead of raw IP datagrams. UDP in binary mode and TCP in
text mode are the perfect building blocks for higher level protocols.
Many client applications only need a small subset of a complex higher
level protocol. To me, something only supporting a few high level
protocols would be next to useless, as, most of the time, I'm designing
and implementing my own (trivial) protocols, on top of UDP or TCP.

But this level of detail should be obviously left to the implementor, as
well as the choice of basic networking protocols supported.

Dan
 
D

Dan Pop

In said:
I don't think he was. We don't have STDIO support in the C syntax
either, have we?

No, but freestanding implementations are free to completely ignore
<stdio.h>, so his point was valid ONLY if the networking support was
in the C syntax. Engage your goddam brain, or it will rust completely!

Dan
 
S

SM Ryan

# Why doesn't the standard library provide (at least basic)
# networking facilities using TCP/IP ?

Because language standards should define the language and not everything
that could be done with the language. Unfortunately many people cannot
cope with a tessellation of standards and so they ended up demanding
monolithic standards including TCP/IP with C, or including I/O with C,
or including IEEE floating point with C, etc. There's already a number
of irrelevant issues in ANS C, like requiring integer arithmetic to be
modulo 2^n instead of letting the implementation define how to cope with
overflow.
 
K

Keith Thompson

SM Ryan said:
# Why doesn't the standard library provide (at least basic)
# networking facilities using TCP/IP ?

Because language standards should define the language and not everything
that could be done with the language. Unfortunately many people cannot
cope with a tessellation of standards and so they ended up demanding
monolithic standards including TCP/IP with C, or including I/O with C,
or including IEEE floating point with C, etc. There's already a number
of irrelevant issues in ANS C, like requiring integer arithmetic to be
modulo 2^n instead of letting the implementation define how to cope with
overflow.

You mean unsigned integer arithmetic, right?
 
H

Harti Brandt

On Wed, 14 Jul 2004, Lew Pitcher wrote:

LP>-----BEGIN PGP SIGNED MESSAGE-----
LP>Hash: SHA1
LP>
LP>Dan Pop wrote:
LP>
LP>> In <[email protected]> Lew Pitcher
LP>>
LP>>
LP>>>Accepted wisdom aside, why /couldn't/ C (in a future incarnation) define
LP>>>a 'networking' interface in the same flavour as it now provides a file
LP>>>access interface?
LP>>
LP>>
LP>> The most likely answer would be: lack of existing practice. So, if some
LP>> popular implementor does it, there are chances for it to become a
LP>> standard feature. Until then, we're in the good old "the egg and
LP>> the hen" deadlock ;-)
LP>
LP>That's an answer I can live with :)
LP>
LP>Until some C implementation actually /implements/ this behaviour, we
LP>won't ever /see/ this behaviour.

You may want to look up a description of the portal filesystem under BSD.
(search on mount_portalfs on www.freebsd.org).

harti

LP>Perhaps we can convince PJP that Dinkumware /needs/ to implement
LP>networking within their stdio library <vbg>
LP>
LP>- --
LP>
LP>Lew Pitcher, IT Consultant, Enterprise Application Architecture
LP>Enterprise Technology Solutions, TD Bank Financial Group
LP>
LP>(Opinions expressed here are my own, not my employer's)
LP>-----BEGIN PGP SIGNATURE-----
LP>Version: GnuPG v1.2.4 (MingW32)
LP>
LP>iD8DBQFA9WdeagVFX4UWr64RAlwbAJ0eTfpv6pxmWKxQHTLDweNQTdbMmACgv3Lt
LP>UYMI3MdTiGE8Qmh3+2TwTCo=
LP>=UOUz
LP>-----END PGP SIGNATURE-----
LP>
 
M

Mark A. Odell

Ben Pfaff said:
You are trying to say that there is an 8-bit microcontroller with
128 bytes of RAM, 8 kB of ROM, and a *hosted* implementation of
C? That'd be a sight to see.

No, I did not mean to imply such a case.
 
M

Mark A. Odell

No, but freestanding implementations are free to completely ignore
<stdio.h>, so his point was valid ONLY if the networking support was
in the C syntax.

Really. So can the compiler vendor claim ISO C compliance in such a case
yet not supply many of the stdio.h functions?
 
D

Dan Pop

In said:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



But, then again, when passed to fopen() as the filename parameter, the
string "c:\\windows\\system32\\etc\\services" isn't required by the
standard either, nor is "/etc/services", or even "DD:SYSIN". But, this
lack of standardization doesn't prevent the use of fopen() in portable code.

Because you can obtain the file name at run time, in various ways.
If you are willing to decry the interpretation of the fopen() 'filename'
"tcp:127.0.0.1:9" as not being required by the standard, then you
probably should also decry "/etc/services" (or for that matter, just
"services") as well.

The point is that, unless the standard requires it, you cannot rely on
fopen() to be usable for network connections *at all*, no matter where
the "filename" comes from. If you don't believe me, try using fopen()
right now for this purpose and tell us on how many implementations your
network client worked.
Ahh, but what is a "file"?

When someone starts splitting hairs, it's better to leave him play his
game alone.

Dan
 
D

Dan Pop

In said:
(e-mail address removed) (Dan Pop) wrote in

Really. So can the compiler vendor claim ISO C compliance in such a case
yet not supply many of the stdio.h functions?

A conforming freestanding implementation shall accept any strictly
conforming program in which the use of the features specified in
the library section ($4) is confined to the contents of the standard
headers <float.h>, <limits.h>, <stdarg.h>, and <stddef.h>.

The list is a bit longer in C99, but it's still restricted to headers
unrelated to the standard C library.

Dan
 
B

Ben Pfaff

Mark A. Odell said:
No, I did not mean to imply such a case.

Then there's no point in using such an example to discount
anything being added to the standard *hosted* C library.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top