 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Siddhartha Gandhi Guest
|
Posted: Mon Apr 09, 2007 6:02 am Post subject: Sockets in C++? |
|
|
It's on the proposal page, any news about it?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Mathias Gaunard Guest
|
Posted: Mon Apr 09, 2007 4:17 pm Post subject: Re: Sockets in C++? |
|
|
On Apr 9, 8:02 am, "Siddhartha Gandhi" <siddharthagandhi...@gmail.com>
wrote:
| Quote: | It's on the proposal page, any news about it?
|
The latest proposal is the one based on boost.asio
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
John Nagle Guest
|
Posted: Tue Apr 10, 2007 2:28 am Post subject: Re: Sockets in C++? |
|
|
Mathias Gaunard wrote:
| Quote: | On Apr 9, 8:02 am, "Siddhartha Gandhi" <siddharthagandhi...@gmail.com
wrote:
It's on the proposal page, any news about it?
The latest proposal is the one based on boost.asio
|
That seems to be a gratuitous wrapper around well-understood
functionality. It also introduces a framework-like callback
model, which is probably inappropriate for the C++ standard
library.
If someone wants to do something useful in this area,
Python's "urllib" would be a better place to start.
John Nagle
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Siddhartha Gandhi Guest
|
Posted: Tue Apr 10, 2007 2:28 am Post subject: Re: Sockets in C++? |
|
|
===================================== MODERATOR'S COMMENT:
Please delete moderation banners when replying.
===================================== END OF MODERATOR'S COMMENT
On Apr 9, 12:17 pm, "Mathias Gaunard" <loufo...@gmail.com> wrote:
| Quote: | On Apr 9, 8:02 am, "Siddhartha Gandhi" <siddharthagandhi...@gmail.com
wrote:
It's on the proposal page, any news about it?
The latest proposal is the one based on boost.asio
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-...@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ:http://www.comeaucomputing.com/csc/faq.html ]
|
Hah, yet another. But any news on the time frame of this?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Apr 10, 2007 4:34 pm Post subject: Re: Sockets in C++? |
|
|
On 9 abr, 23:28, John Nagle <n...@animats.com> wrote:
| Quote: | Mathias Gaunard wrote:
On Apr 9, 8:02 am, "Siddhartha Gandhi" <siddharthagandhi...@gmail.com
wrote:
It's on the proposal page, any news about it?
The latest proposal is the one based on boost.asio
That seems to be a gratuitous wrapper around well-understood
functionality. It also introduces a framework-like callback
model, which is probably inappropriate for the C++ standard
library.
If someone wants to do something useful in this area,
Python's "urllib" would be a better place to start.
|
I've played with designs for exposing socket primitives in C++ in
various manners.
I used to think that the best approach was to hide, somehow, the
"primitive" functions and just expose wrapper classes like socket,
listener, selector, and the like. I figured this because <iostream>
doesn't expose anything.
But then there is this proposal of a threading library that sort of
standardize pthreads.
Is this the approach the committee would prefer?
A standardized <csocket> thing or something?
On a side note I've recently requested membership on the mailing list
of the "POSIX C++" working group. I want to ask this question to them
too.
--
Pedro Lamarão
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Mathias Gaunard Guest
|
Posted: Tue Apr 10, 2007 4:36 pm Post subject: Re: Sockets in C++? |
|
|
On Apr 10, 4:28 am, John Nagle <n...@animats.com> wrote:
| Quote: | That seems to be a gratuitous wrapper around well-understood
functionality.
|
I doubt the design of networking applications is that well understood,
especially asynchronous ones.
And I won't call asio gratuitous, since it is definitely a novative
design, way cleaner than ACE or similar older libraries.
| Quote: | It also introduces a framework-like callback
model, which is probably inappropriate for the C++ standard
library.
|
I don't see how it is inappropriate.
Callbacks is the cleanest way to handle asynchronous I/O, and the most
portable one.
Callbacks anyway are underused in the C++ standard library, there are
multiple places where you could use them for delayed evaluation,
delegating invocation, closures... They're a Good Thing.
I honestly don't see what your reluctance to callbacks is based on.
The point of this proposal is to provide a powerful, efficient, safe
and portable way to handle networking. Putting it in the standard
allows abstraction from the underlying environment.
And asynchronous I/O is important, unless you only want to make the
networking library a very limited subset of the OS functionality,
making lot of people people use the OS-specific libraries instead of
the standard one.
| Quote: | If someone wants to do something useful in this area,
Python's "urllib" would be a better place to start.
|
That's not networking, but a much higher-level wrapper library that
works in the application layer and not the network or transport layer.
And to write that, you need the basic building blocks of low-level
networking anyway.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
John Nagle Guest
|
Posted: Tue Apr 10, 2007 6:56 pm Post subject: Re: Sockets in C++? |
|
|
Mathias Gaunard wrote:
| Quote: | On Apr 10, 4:28 am, John Nagle <n...@animats.com> wrote:
That seems to be a gratuitous wrapper around well-understood
functionality.
I doubt the design of networking applications is that well understood,
especially asynchronous ones.
And I won't call asio gratuitous, since it is definitely a novative
design, way cleaner than ACE or similar older libraries.
It also introduces a framework-like callback
model, which is probably inappropriate for the C++ standard
library.
I don't see how it is inappropriate.
Callbacks is the cleanest way to handle asynchronous I/O, and the most
portable one.
Callbacks anyway are underused in the C++ standard library, there are
multiple places where you could use them for delayed evaluation,
delegating invocation, closures... They're a Good Thing.
I honestly don't see what your reluctance to callbacks is based on.
|
The basic problem with callback-based approaches is that they
tend to work only when there's only one of them. That's why they're
more a "framework" feature than a "library" feature. It's usually
very difficult to mix framework models.
Generally, the Standard C++ libraries have been careful to adhere
to a "library" model, where user code calls libraries, rather than a
"framework" model, where the library calls user code. This should
continue.
Once you start using a callback-based framework, you have to do
everything that can delay via that framework. Otherwise you stall the
callback engine. So the introduction of a callback-based framework
determines the overall design of the program.
That's why they don't belong in the standard library.
John Nagle
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Malte Clasen Guest
|
Posted: Wed Apr 11, 2007 7:08 am Post subject: Re: Sockets in C++? |
|
|
John Nagle wrote:
| Quote: | Generally, the Standard C++ libraries have been careful to adhere
to a "library" model, where user code calls libraries, rather than a
"framework" model, where the library calls user code. This should
continue.
|
However, I tend to think of function objects as some kind of callback
that is already existing in the standard library. I think passing a
custom strict weak ordering to sort() as an object is more intuitive and
useful than providing the building blocks for a custom sort algorithms
just to stick with the library paradigm.
Best regards,
Malte
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
John Nagle Guest
|
Posted: Wed Apr 11, 2007 7:16 am Post subject: Re: Sockets in C++? |
|
|
Malte Clasen wrote:
| Quote: | John Nagle wrote:
Generally, the Standard C++ libraries have been careful to adhere
to a "library" model, where user code calls libraries, rather than a
"framework" model, where the library calls user code. This should
continue.
However, I tend to think of function objects as some kind of callback
that is already existing in the standard library. I think passing a
custom strict weak ordering to sort() as an object is more intuitive and
useful than providing the building blocks for a custom sort algorithms
just to stick with the library paradigm.
|
Sorting doesn't impose an event-driven structure on the whole program.
A callback-oriented communications structure does.
John Nagle
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Mathias Gaunard Guest
|
Posted: Wed Apr 11, 2007 6:49 pm Post subject: Re: Sockets in C++? |
|
|
On Apr 10, 8:56 pm, John Nagle <n...@animats.com> wrote:
| Quote: | Once you start using a callback-based framework, you have to do
everything that can delay via that framework. Otherwise you stall the
callback engine. So the introduction of a callback-based framework
determines the overall design of the program.
|
An obvious solution is to run the whole engine in its own thread.
However, doing so automatically would reduce the user's control, who
couldn't choose on which thread (or pool of threads) he wants to run
it on.
As far as I can see, the POSIX asynchronous I/O interface works more
or less that way. You attach callbacks and those are called once the
work is finished, but you don't need to initiate a loop.
For asynchronous I/O, you either need a system that notice you once
the work is finished (proactor pattern), or a system which you can
query to know when it's ready for work (reactor pattern).
The proactor pattern is not only way easier to use, but also it can
take advantage of OS features like Windows overlapped I/O. And it can
be implemented on top of the reactor pattern, that some OSes (most
unices) have support for.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
John Nagle Guest
|
Posted: Wed Apr 11, 2007 10:47 pm Post subject: Re: Sockets in C++? |
|
|
James Kanze wrote:
| Quote: | On Apr 11, 4:08 am, malte.cla...@arcor.de (Malte Clasen) wrote:
John Nagle wrote:
Generally, the Standard C++ libraries have been careful to adhere
to a "library" model, where user code calls libraries, rather than a
"framework" model, where the library calls user code. This should
continue.
However, I tend to think of function objects as some kind of callback
that is already existing in the standard library. I think passing a
custom strict weak ordering to sort() as an object is more intuitive and
useful than providing the building blocks for a custom sort algorithms
just to stick with the library paradigm.
I think his objection was to an asynchronous callback. (I'm not
familiar with boost.asio, but that's what the name suggests.)
There'a big difference between a callback that is called from
within the function, and one which is called asynchronously,
some time later.
|
Yes, that's right.
The basic concept of Boost's "asio" is that "boost::asio::demuxer::run()"
owns the main event loop and calls everything else. That's a framework, not a
library.
Frameworks tend to take over the program design. Try using "asio".
and some GUI framework which also wants to own the event loop, in the
same program. Sometimes multiple frameworks can be made to play together
using multiple threads, but it's usually not easy.
That's why I'd argue against including something like "asio" in the
Standard C++ library. There's nothing wrong with creating frameworks,
but they're not library components.
John Nagle
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Pedro Lamarão Guest
|
Posted: Thu Apr 12, 2007 3:32 am Post subject: Re: Sockets in C++? |
|
|
On 11 abr, 15:49, "Mathias Gaunard" <loufo...@gmail.com> wrote:
| Quote: | As far as I can see, the POSIX asynchronous I/O interface works more
or less that way. You attach callbacks and those are called once the
work is finished, but you don't need to initiate a loop.
|
The aiocb structure is required to have these members:
int aio_fildes File descriptor.
off_t aio_offset File offset.
volatile void *aio_buf Location of buffer.
size_t aio_nbytes Length of transfer.
int aio_reqprio Request priority offset.
struct sigevent aio_sigevent Signal number and value.
int aio_lio_opcode Operation to be performed.
Notice there isn't a void* handler data member to keep a callback
around.
AIO works as the "proactor pattern" you mention: you can poll call
aio_suspend on an array of aiocb objects to receive completion
notification.
--
Pedro Lamarão
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Mathias Gaunard Guest
|
Posted: Thu Apr 12, 2007 5:51 am Post subject: Re: Sockets in C++? |
|
|
On Apr 12, 5:32 am, "Pedro Lamarão" <pedro.lama...@gmail.com> wrote:
| Quote: | The aiocb structure is required to have these members:
int aio_fildes File descriptor.
off_t aio_offset File offset.
volatile void *aio_buf Location of buffer.
size_t aio_nbytes Length of transfer.
int aio_reqprio Request priority offset.
struct sigevent aio_sigevent Signal number and value.
int aio_lio_opcode Operation to be performed.
Notice there isn't a void* handler data member to keep a callback
around.
|
It's in aio_sigevent.
aio_sigevent.notify_function
See http://www-128.ibm.com/developerworks/linux/library/l-async/index.html
for a simple tutorial.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Gianni Mariani Guest
|
Posted: Thu Apr 12, 2007 9:10 am Post subject: Re: Sockets in C++? |
|
|
John Nagle wrote:
..
| Quote: | Yes, that's right.
The basic concept of Boost's "asio" is that
"boost::asio::demuxer::run()"
owns the main event loop and calls everything else. That's a framework,
not a
library.
Frameworks tend to take over the program design. Try using "asio".
and some GUI framework which also wants to own the event loop, in the
same program. Sometimes multiple frameworks can be made to play together
using multiple threads, but it's usually not easy.
That's why I'd argue against including something like "asio" in the
Standard C++ library. There's nothing wrong with creating frameworks,
but they're not library components.
|
What's all this phobia over call backs.
An event based model is congruous to a callback model.
In the latest (unreleased) version of Austria C++ - (alpha available
http://netcabletv.org/public_releases/), it contains a framework that
follows a callback paradigm. I have not found that it limits anything
in any way. (The callback interfaces are called twins in the Austria C++
impl).
Please explain what exactly is limiting in your mind ?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
John Nagle Guest
|
Posted: Thu Apr 12, 2007 9:11 am Post subject: Re: Sockets in C++? |
|
|
Mathias Gaunard wrote:
| Quote: | On Apr 10, 8:56 pm, John Nagle <n...@animats.com> wrote:
Once you start using a callback-based framework, you have to do
everything that can delay via that framework. Otherwise you stall the
callback engine. So the introduction of a callback-based framework
determines the overall design of the program.
An obvious solution is to run the whole engine in its own thread.
However, doing so automatically would reduce the user's control, who
couldn't choose on which thread (or pool of threads) he wants to run
it on.
|
Then you have to address thread-safety issues. If you want
to change "asio" list of work to do, and it has its own thread, how and
what do you lock? "asio" would need a lock that's locked when
"asio" isn't in its waiting state. That doesn't seem to have been
addressed.
John Nagle
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|