Sign in to follow this  
MichaelBarth

Choosing a Library

Recommended Posts

I've learned a lot about game programming and solving problems when they arise, and I can program with SDL, with some OpenGL. Right now I want to learn about network programming, and I'm having difficulty choosing a library. SDL_net is the first thing that comes to mind, but I guess people aren't too impressed by it. Boost.Asio is a possibility, but from the looks of it, it's C++ as opposed to plain C. I may be wrong. I'm looking for a cross compatible networking library that can work under plain C and/or C++. Any recommendations are appreciated.

Share this post


Link to post
Share on other sites
if you are on unix then look into sockets.. thats plain c. But why don't you use c++ ?? On which OS does C++ not compile?

Boost::Asio is a great library and its more than worth the effort to learn and understand it. ACE Is also quite cool, i came across it when checking out the source code for some open source WoW Client.

Share this post


Link to post
Share on other sites
[quote name='FlyingDutchman' timestamp='1335120610' post='4933837']
if you are on unix then look into sockets.. thats plain c. But why don't you use c++ ?? On which OS does C++ not compile?

Boost::Asio is a great library and its more than worth the effort to learn and understand it. ACE Is also quite cool, i came across it when checking out the source code for some open source WoW Client.
[/quote]

It's not that C++ doesn't compile or anything like that. Currently I'm using Windows, but I multiboot with other Unix based operating systems. I just want to stay away from C++ when I don't need it. I'm moving down to lower level languages slowly, but surely, and I don't want to go soft and use higher level languages. I'm learning Assembly and I play to make a minimalistic GUI OS soon, meaning C++ is out. Another plus about C (pun intended) is that it's easier to port something created in it to another operating system.

Anyway, I'm into SDL_net right now and I've seen mixed opinions about ACE. If there's another recommended library, I'll look into that.

Share this post


Link to post
Share on other sites
[quote name='Spirrwell' timestamp='1335127234' post='4933860']
Another plus about C (pun intended) is that it's easier to port something created in it to another operating system.[/quote]Is it? As FlyingDutchman says - on which OS would there be problems? Do you mean that some OSs don't support more advanced C++ functions so well, or that there are intrinsic problems even if it is supported?

I guess if you're planning on writing your own OS, you probably have more obscure OSs in mind than we are thinking of [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] - but then, isn't the problem with any library that people suggest going to have problems that, even if it's "cross-platform", there will always be some platforms it doesn't support?

Share this post


Link to post
Share on other sites
[quote]Another plus about C (pun intended) is that it's easier to port something created in it to another operating system.[/quote]

Not quite, it's only easier if application was written for POSIX and your OS is POSIX as well and you target x86 hardware, even ARM quickly becomes a mess, requiring compiler patches and manual opcode debugging due to multiple instruciton sets and whatnot. Linux and Unix are considered "easy" to port between since they're all mostly POSIX-compliant, so the concept of files, memory, network is well defined. A Windows application however is next to impossible to port. Consider a MFC with DX and Excel COM built in. Might be written in ANSI C, but there's simply nothing you can reuse. Even cross-compilation won't help.

Networking libraries which are openly available are almost exclusively built for either Berkeley sockets, kqueue, epoll or IOCP (Windows).

C counterpart to boost::asio is [url="http://libevent.org/"]libevent[/url]. It lists specific requirement of POSIX or POSIX-like networking APIs it supports.

If building POSIX compliant OS, then you will be providing completely standard Berkeley socket APIs and related file system. In that case, any of the libraries, be it C, C++ or Java will work.

[quote]I'm looking for a cross compatible networking library that can work under plain C and/or C++[/quote]

I'm not aware of anything like that, the best way to call it would be user-space TCP/IP stack implementation. While toy projects were done in that direction, I don't know of any production-grade software.

Such a library would contain hooks to NIC (or similar) hardware directly. Work at that level is done, but it's for different purposes.

Share this post


Link to post
Share on other sites
[quote name='flodihn' timestamp='1335182890' post='4934065']
I am impressed by SDL_Net, I have been using it in my client for years and it works great.
Why would you not want to use it?
[/quote]

I actually asked lazyfoo about it. I'm sure almost anybody who's written in SDL knows about his tutorials. He said that he wasn't a fan of SDL_net when he used it and to check out Boost. Right now I'm working with SDL_net and this other great library, ENet.

[quote name='Antheus' timestamp='1335190390' post='4934101']

[quote]Another plus about C (pun intended) is that it's easier to port something created in it to another operating system.[/quote]

Not quite, it's only easier if application was written for POSIX and your OS is POSIX as well and you target x86 hardware, even ARM quickly becomes a mess, requiring compiler patches and manual opcode debugging due to multiple instruciton sets and whatnot. Linux and Unix are considered "easy" to port between since they're all mostly POSIX-compliant, so the concept of files, memory, network is well defined. A Windows application however is next to impossible to port. Consider a MFC with DX and Excel COM built in. Might be written in ANSI C, but there's simply nothing you can reuse. Even cross-compilation won't help.

Networking libraries which are openly available are almost exclusively built for either Berkeley sockets, kqueue, epoll or IOCP (Windows).

C counterpart to boost::asio is [url="http://libevent.org/"]libevent[/url]. It lists specific requirement of POSIX or POSIX-like networking APIs it supports.

If building POSIX compliant OS, then you will be providing completely standard Berkeley socket APIs and related file system. In that case, any of the libraries, be it C, C++ or Java will work.

[quote]I'm looking for a cross compatible networking library that can work under plain C and/or C++[/quote]

I'm not aware of anything like that, the best way to call it would be user-space TCP/IP stack implementation. While toy projects were done in that direction, I don't know of any production-grade software.

Such a library would contain hooks to NIC (or similar) hardware directly. Work at that level is done, but it's for different purposes.
[/quote]

Well I was simply thinking of how certain obscure operating systems don't have C++ capability or they haven't rewritten C++ to get it to work. As I understand you'd have to rewrite new and delete functions and such that are dependent on the OS it runs on to work. I don't understand that, but that's what I've picked up while learning Assembly. Hell I even have this 64 bit operating system called MenuetOS that can be run on a 1.4 MB floppy as it's written entirely in Assembly.

Thank you for your time.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this