473,765 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why not networking support?

Why doesn't the standard library provide (at least basic)
networking facilities using TCP/IP ?
Nov 14 '05
46 2126
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mark A. Odell wrote:
Joona I Palaste <pa*****@cc.hel sinki.fi> wrote in
news:cd******** **@oravannahka. helsinki.fi:

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

Instead of trying to answer my question, think about it. It's supposed
to contain the answer to your question.


Umm... I know! I think. Can I answer for the OP?

Me too, I think because then someone would ask, "Why not DeviceNET" and


I was going to ask "Why not SNA?"
then we'd add that to C and next thing you know, C would only be able to
run on hosted implementations .

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 same caveats and exceptions for hosted vs unhosted
that currently apply to the stdio library could be applied to this
hypothetical stdnet library.

To take it a step further, how about abstracting network access into the
implementation of the stdio library? This way, the language wouldn't
have to change to provide networking features. To show what I mean, take
the following example program:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
FILE *data;

if ((data = fopen("data","w ")) != NULL)
fprintf(data,"H ello, World\n");
fclose(data);

return EXIT_SUCCESS;
}

The above program /obviously/ writes to a file called "data". Now, look
at this minor modification:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
FILE *data;

if ((data = fopen("tcp:127. 0.0.1:9","w")) != NULL)
fprintf(data,"H ello, World\n");
fclose(data);

return EXIT_SUCCESS;
}

Does the above program write to the file called "tcp:127.0.0.1: 9", or
does it establish a TCP connection with the local discard service and
send it some data? Does it matter, wrt ISO C?


- --

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)

iD8DBQFA9DjmagV FX4UWr64RAo83AJ 48OYnhgsXXDkllL 1ssype0VxMBVwCg qGyU
oZScRtcwsOC0yBB 5H/kp8aE=
=5DqQ
-----END PGP SIGNATURE-----
Nov 14 '05 #11

On Tue, 13 Jul 2004, Lew Pitcher wrote:

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 same caveats and exceptions for hosted vs unhosted
that currently apply to the stdio library could be applied to this
hypothetical stdnet library.
Probably because it wouldn't be useful (which AFAICT was Dan's original
point). 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.
Why TCP/IP when what I *really* need is DS/IP (DeathStation Internet
Protocol)? :)
To take it a step further, how about abstracting network access into the
implementation of the stdio library? This way, the language wouldn't
have to change to provide networking features. To show what I mean, take
the following example program: <snip> if ((data = fopen("tcp:127. 0.0.1:9","w")) != NULL)

Does the above program write to the file called "tcp:127.0.0.1: 9", or
does it establish a TCP connection with the local discard service and
send it some data? Does it matter, wrt ISO C?


Doesn't matter at all. The networking solution is definitely a
perfectly reasonable behavior for a Windows compiler, since Windows
these days blurs the lines between the filesystem and the network
to the point of non-existence (merging Internet Explorer and File
Manager, e.g.). In a compiler explicitly targeted to Windows, I would
definitely expect that fopen("http://www.google.com/", "r") would
behave as if it were reading from a "normal" file full of HTML.
I don't know how much Linux or other OSen blur these lines, though;
I would expect the answer to be "less."

-Arthur
Nov 14 '05 #12
Lew Pitcher wrote:
[...]
To take it a step further, how about abstracting network access into the
implementation of the stdio library? This way, the language wouldn't
have to change to provide networking features. To show what I mean, take
the following example program:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
FILE *data;

if ((data = fopen("data","w ")) != NULL)
fprintf(data,"H ello, World\n");
fclose(data);

return EXIT_SUCCESS;
}

The above program /obviously/ writes to a file called "data". Now, look
at this minor modification:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
FILE *data;

if ((data = fopen("tcp:127. 0.0.1:9","w")) != NULL)
fprintf(data,"H ello, World\n");
fclose(data);

return EXIT_SUCCESS;
}

Does the above program write to the file called "tcp:127.0.0.1: 9", or
does it establish a TCP connection with the local discard service and
send it some data? Does it matter, wrt ISO C?


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.)

For a concrete example of how different implementations
give different interpretations to identical file name strings,
try this program on several implementations and observe what
happens:

#include <stdio.h>
static void doit(const char *name, const char *text) {
FILE *stream = fopen(name, "w");
if (stream == NULL)
fprintf (stderr, "Can't open %s\n", name);
else {
fprintf (stream, "%s: %s\n", name, text);
fclose (stream);
}
}
int main(void) {
doit ("pro.txt", "Reasons to support euthanasia");
doit ("con.txt", "Reasons to oppose euthanasia");
return 0;
}

Another way to sneak new capabilities into the existing
Standard library interface would be to extend the "mode" string,
with implementation-defined significance for extra characters:

stream = fopen("127.0.0. 1:9", "wbTCP");

.... where the Standard defines the "wb" piece and the "TCP"
is a hypothetical implementation-specific add-on -- "undefined"
by the C Standard, but "definable" by cooperating extensions.

--
Er*********@sun .com

Nov 14 '05 #13
H.A. Sujith wrote:
Why doesn't the standard library provide (at least basic)
networking facilities using TCP/IP?


Why should it?
What's wrong with the current standards?
Why must C compiler developers implement and distribute
a standard library for networking facilities?
Nov 14 '05 #14
"Mark A. Odell" <od*******@hotm ail.com> wrote in message
news:Xn******** *************** ********@130.13 3.1.4...
"H.A. Sujith" <su****@localho st.localdomain> wrote in
news:slrncf7icc .2sr.su****@loc alhost.localdom ain:
Why doesn't the standard library provide (at least basic)
networking facilities using TCP/IP ?


What does that mean to an 8-bit microcontroller with 128 bytes of RAM and
8kB of ROM?


What's your point in asking this question?

--
Peter
Nov 14 '05 #15
Lew Pitcher <Le*********@td .com> wrote:
Mark A. Odell wrote:
then we'd add that to C and next thing you know, C would only be able to
run on hosted implementations .


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 same caveats and exceptions for hosted vs unhosted
that currently apply to the stdio library could be applied to this
hypothetical stdnet library.


Because networking is even less standardised than file systems. With a
file system at least you know that
- you have files, with names;
- files can be read, and written to;
- files may need to be opened, possibly in varying modes, and closed,
and where these are unnecessary, they're trivial no-ops;
- file operations may fail, but these failures can be detected.

With networks, things are not that simple. Some kinds of networks need
you to authenticate yourself, using name and password, before you can do
anything else. Some kinds don't allow you to authenticate, but may use
your network address to decide whether you're allowed to talk. Some
network services work directly; some use repeated question-and-response;
some set up a continuous connection. And whose abstraction model would
we use? OSI?

Richard
Nov 14 '05 #16
In article <cd**********@n ntp1.jpl.nasa.g ov>, E. Robert Tisdale wrote:
H.A. Sujith wrote:
Why doesn't the standard library provide (at least basic)
networking facilities using TCP/IP?


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.

--
mail to: randomzoo <at> spymac <dot> com
Nov 14 '05 #17
On 14 Jul 2004 07:49:22 -0700,
H.A. Sujith <su****@localho st.localdomain> wrote
in Msg. <slrncfa831.16p .su****@localho st.localdomain>
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.


Ever heard of POSIX?

--Daniel

--
"With me is nothing wrong! And with you?" (from r.a.m.p)
Nov 14 '05 #18
"Peter Nilsson" <ai***@acay.com .au> wrote in
news:40******@n ews.rivernet.co m.au:
> Why doesn't the standard library provide (at least basic)
> networking facilities using TCP/IP ?


What does that mean to an 8-bit microcontroller with 128 bytes of RAM
and 8kB of ROM?


What's your point in asking this question?


That a TCP/IP stack would be difficult to fit in addition to what the
current ISO C compiler supports. Basically, C can be used, as it stands,
on many smaller devices - adding TCP/IP would make C more of a "big
system" language. Unnecessarily I might add.

--
- Mark ->
--
Nov 14 '05 #19
"H.A. Sujith" <su****@localho st.localdomain> wrote:
In article <cd**********@n ntp1.jpl.nasa.g ov>, E. Robert Tisdale wrote:
H.A. Sujith wrote:
Why doesn't the standard library provide (at least basic)
networking facilities using TCP/IP?


Why should it?


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


No, it has not. It has become _an_ accepted standard. Not _the_. IPX is
not yet dead, for example.

Richard
Nov 14 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2422
by: Fibre Optic | last post by:
Hi, I am looking for good book about network programming in C++. Probably it will difficult to find out book which explain such complicated subject for MS Windows & Linux but ... Could some one tell me few good books on this field ? Does anyone have experience witch ACE library ? Is it only high level of network programming, is it possible to write i.e. TFTP/FTP server with this library ?
5
1476
by: KevinGPO | last post by:
Two quick queries: 1. I have programmed a little network performance monitor. It monitors a set of remote hosts over a network. It gets the CPU statistics and all gets collected at one of the remote hosts (say primary remote host, holding procValues, 4 CPU floating numbers per n remote hosts). Now, I want to transfer this data set (double procValues) over a TCP or UDP network connection to a local host for graphing and storing in a...
7
8926
by: Brian Keogh | last post by:
Hi, I'm a student learning TCP/IP networking at University. Although I understand all about TCP/IP Networking in Java I am expected to understand the basics of C with regard to these programs as all the examples in my course notes and Exams refer to C. Can someone please point me in the right direction to where I might find answers on the web explaining C code involved with TCP/IP networking and what they mean. These are quite basic I'm...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7375
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.