|
Home > Archive > Unix Programming > January 2006 > Is IPv6 C++-oriented?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Is IPv6 C++-oriented?
|
|
| Alex Vinokur 2006-01-22, 6:11 pm |
| IPv4
----
char* buffer = malloc (len);
int recv(int s, void *buffer, size_t len, int flags);
To use recv() in IPv4 we should allocate buffer of maximum allowed size
before calling recv().
On other hand, C++ STL enables us to fill buffer without allocating
memory before calling functions (for instance, using stringstream)
Does IPv6 use such a property of C++?
In this case the recv6() might be as follows:
// No memory allocation.
int recv6 (int s, stringstream* ss, int flags);
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn
| |
| Nils O. Selåsdal 2006-01-22, 6:11 pm |
| Alex Vinokur wrote:
> IPv4
> ----
> char* buffer = malloc (len);
> int recv(int s, void *buffer, size_t len, int flags);
>
> To use recv() in IPv4 we should allocate buffer of maximum allowed size
> before calling recv().
>
> On other hand, C++ STL enables us to fill buffer without allocating
> memory before calling functions (for instance, using stringstream)
>
>
> Does IPv6 use such a property of C++?
IPv6 is a protocol, it's not directly related to a specific programming
language.
The standard BSD socket API is a C API ,and is quite similar for ipv4
and ipv6. Search for a library for C++ that has the feature you want,
maybe someone has constructed such a library.
| |
| Alex Colvin 2006-01-29, 9:32 pm |
| =?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?= <noselasd@asgaard.removethis.homelinux.org> writes:
[vbcol=seagreen]
Not really.
The c++ library classes reallocate the buffer and copy the data as the
buffer grows. That means these operations are usually fast, but now and
then they have to do a lot of extra work.
When you've got messages streaming in off the wire, there's simply no time
for that.
Perhaps more significantly, the data stream has to know intimate details
of the buffer management software. The kernel protocol stack doesn't know
this about your application. You could build an operating system that was
this tightly integrated, but you'd have to rebuild the kernel everytime
you updated a library.
The usual way to hide this is to pre-allocate a maximum-size buffer and
then, once the data is in, reallocate it to the size actually used.
--
mac the naïf
|
|
|
|
|