[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

Coming back from C to C++

Tomás Ó hÉilidhe

10/30/2008 3:09:00 PM


I started out with C++ about 8 years ago, but in the last two years or
so I switched to doing a lot of C programming, so I've been out of the
loop for a while.

Anyway I've a few quick questions to ask:

Currently what's the biggest integer type in C++? Does C++ have all
the <stdint.h> types such as uint_fast64_t? I use these types a lot.
Back when I did C++ programming a few years ago, I don't think all C++
implementations were guaranteed to have <stdint.h>. Have things
changed? Also, does C++ have the "long long" integer type that's
guaranteed to be at least 64-Bit?

At the moment I'm working on a multi-threaded networking application
that will have about three threads. One thread will be updating the
screen (which will just be a console program displaying text), one
thread will be sniffing for packets, and another thread will be
sending packets.

I've heard something along the lines of "boost" threads being adopted
into the C++ standard, is this true? What's the most portable multi-
threading library for C++ (I'd like my program to be able to run on as
many kinds of machine as possible).

Another thing: Can anyone suggest what's the most portable networking
library for sending and receiving raw Ethernet frame? In the world of
C, "Berkeley Sockets" seems to be the main one. What about C++, what's
the best networking library to use if you're looking to maximise
portability? (Remember that I need to be able to send and receive full
Ethernet frames).

And one last thing: My program won't have a fancy GUI, it'll just be a
console application. I realise that neither the C nor C++ standard
libraries provide fancy facilities for setting the text colour, but
I'm wondering is there a portable library out there for doing this? I
recall using "conio.h" a few years ago but I don't know if this is the
"de facto" standard.
3 Answers

red floyd

10/30/2008 4:43:00 PM

0

On Oct 30, 8:08 am, Tomás Ó hÉilidhe <t...@lavabit.com> wrote:

> Another thing: Can anyone suggest what's the most portable networking
> library for sending and receiving raw Ethernet frame? In the world of
> C, "Berkeley Sockets" seems to be the main one. What about C++, what's
> the best networking library to use if you're looking to maximise
> portability? (Remember that I need to be able to send and receive full
> Ethernet frames).
>
Berkeley Sockets.


> And one last thing: My program won't have a fancy GUI, it'll just be a
> console application. I realise that neither the C nor C++ standard
> libraries provide fancy facilities for setting the text colour, but
> I'm wondering is there a portable library out there for doing this? I
> recall using "conio.h" a few years ago but I don't know if this is the
> "de facto" standard.
For what platform? "conio.h" is a DOS-ism. In the Unix world,
ncurses (<curses.h>)
is more popular and portable. It all depends. Ask in a group
dedicated to your
platform.


gpderetta

10/30/2008 5:33:00 PM

0

On Oct 30, 4:08 pm, Tomás Ó hÉilidhe <t...@lavabit.com> wrote:
>
> I've heard something along the lines of "boost" threads being adopted
> into the C++ standard, is this true? What's the most portable multi-
> threading library for C++ (I'd like my program to be able to run on as
> many kinds of machine as possible).
>

More or less. The current thread support in the draft standard is
inspired on boost.thread but it not the same. About portability, boost
thread works on many Windows variant and on most platforms that
support pthreads. Otherwise you could just program on top of pthreads.
Pthread implementations for windows do exist.

> Another thing: Can anyone suggest what's the most portable networking
> library for sending and receiving raw Ethernet frame? In the world of
> C, "Berkeley Sockets" seems to be the main one. What about C++, what's
> the best networking library to use if you're looking to maximise
> portability? (Remember that I need to be able to send and receive full
> Ethernet frames).
>

Boost.Asio, which is based on Berkeley Sockets, simplifies synchronous
or asychronous network programming. I'm fairly sure it support raw
sockets. Failing that you can also try ACE or straight Berkeley
Sockets.

--
Giovanni P. Deretta

dascandy@gmail.com

11/1/2008 8:39:00 AM

0

On Oct 30, 4:08 pm, Tomás Ó hÉilidhe <t...@lavabit.com> wrote:
> Currently what's the biggest integer type in C++? Does C++ have all
> the <stdint.h> types such as uint_fast64_t? I use these types a lot.
> Back when I did C++ programming a few years ago, I don't think all C++
> implementations were guaranteed to have <stdint.h>. Have things
> changed? Also, does C++ have the "long long" integer type that's
> guaranteed to be at least 64-Bit?

Not yet, and not yet. Both should be added in c++09, which will be (as
you can tell) next year.

> Another thing: Can anyone suggest what's the most portable networking
> library for sending and receiving raw Ethernet frame? In the world of
> C, "Berkeley Sockets" seems to be the main one. What about C++, what's
> the best networking library to use if you're looking to maximise
> portability? (Remember that I need to be able to send and receive full
> Ethernet frames).

Berkeley sockets or pcap-derived things. I think berkeley sockets are
the more portable one.

> And one last thing: My program won't have a fancy GUI, it'll just be a
> console application. I realise that neither the C nor C++ standard
> libraries provide fancy facilities for setting the text colour, but
> I'm wondering is there a portable library out there for doing this? I
> recall using "conio.h" a few years ago but I don't know if this is the
> "de facto" standard.

That depends on the kind of console somebody has. You could use a
library like ncurses to wrap that for you or you can do it yourself.