Choosing a Library
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.
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.
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.
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.
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.
Hey man, i went that way too so just do it :-) It is also quite sexy to code in plain C :-) I was just curious because if its not for learning purposes its a big waste off time.
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?
Why would you not want to use it?
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?
Another plus about C (pun intended) is that it's easier to port something created in it to another operating system.
I guess if you're planning on writing your own OS, you probably have more obscure OSs in mind than we are thinking of - 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?
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 libevent. 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.
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.
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?
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.
Another plus about C (pun intended) is that it's easier to port something created in it to another operating system.
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 libevent. 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.
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.
(I know this is late, but I want to chime in):
Have you checked out Raknet? I've used it on 2 different projects, and I think it's great.
Have you checked out Raknet? I've used it on 2 different projects, and I think it's great.
For a low-level library that's robust, try Enet.
For a high-level library, try something like RakNet.
For a high-level library, try something like RakNet.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement