Page 1 of 1
irrNetz (another lightweight enet wrapper)
Posted: Mon Mar 26, 2012 5:30 pm
by tbw
Hello,
for my techdemo I needed some network code. BlindSide implemented irrNet and irrNetLite, so why another wrapper? The answer is very simple:
At first I wanted to get a little bit closer to game network code programming. The second reason was, I wanted to use the latest enet code (1.3.3), which comes already with compression code (range coder), so the reference to zlib is not needed any longer. Furthermore I wanted the code to be a little bit more irrLicht style.
Here is the result. At the moment there is only a simple server and a simple client sample. But I will soon add a chat sample with irrlicht gui and a game lobby sample.
My dev system is win7/MS-VisualStudio so it would be nice if someone could compile and test it on other platforms/dev systems.
http://www.van-helsing-band.de/irrlicht/irrNetz.zip
Re: irrNetz (another lightweight enet wrapper)
Posted: Tue Mar 27, 2012 10:33 am
by REDDemon
very interesting. thanks for sharing
Re: irrNetz (another lightweight enet wrapper)
Posted: Wed Mar 28, 2012 4:52 am
by Virion
haven't have time to test this out, but it does sound interesting. good job man.
Re: irrNetz (another lightweight enet wrapper)
Posted: Mon Apr 09, 2012 7:58 pm
by Midnight
Isn't this C++ and C mixed without proper externs???
Re: irrNetz (another lightweight enet wrapper)
Posted: Tue Apr 10, 2012 8:35 am
by tbw
Yes it is c mixed with c++, but I think the enet header (enet.h) itself ensures the proper use of "extern":
Code: Select all
...
#ifdef __cplusplus
extern "C"
{
#endif
...
so I hope that everthing is correct.
Re: irrNetz (another lightweight enet wrapper)
Posted: Tue Apr 10, 2012 2:13 pm
by Midnight
yes enet is protected, and your code is mostly correct as well (printf = c++)
but in your examples you're using _getch() and _kbhit().
Those are C if I'm not mistaken and I occasionally am. On that note I'm not trying to make a big deal of it, just thought I'd point that out in practice.
Re: irrNetz (another lightweight enet wrapper)
Posted: Tue Apr 10, 2012 2:18 pm
by hendu
Using C from C++ code = not bad
Using Windows-only functions in examples for portable code = bad
Re: irrNetz (another lightweight enet wrapper)
Posted: Tue Apr 10, 2012 2:21 pm
by Midnight
is that what it is? Yeah we've gone down the C&Cpp debate road enuff... as a matter of fact MSDN is telling me conio and those two functions from it are proper for all versions of the C Runtime libraries so it is actually c++ anyway I guess.
At any rate I've gained knowledge from your code and I thank you for that.
Re: irrNetz (another lightweight enet wrapper)
Posted: Tue Apr 10, 2012 4:29 pm
by hendu
MS's C runtime, not any standard. Conio is only supported on Windows (/ late DOS).
Re: irrNetz (another lightweight enet wrapper)
Posted: Tue Apr 10, 2012 7:11 pm
by tbw
Yeah, I didn't realize that conio is msvc only.
Replacing
Code: Select all
while(!(_kbhit() && _getch()=='q') && peer->getState() == net::ECS_CONNECTED)
with
Code: Select all
while(peer->getState() == net::ECS_CONNECTED)
should do fine.
The problem I ran into was the generation of memory leaks when terminating the program because the final drop statements for objects were not reached...
EDIT:
on the server side the while statement should look like this:
Re: irrNetz (another lightweight enet wrapper)
Posted: Wed Apr 18, 2012 9:37 pm
by Midnight
Ideally you could mix it with some irrlicht like demo, using irrlicht events for keys. this is (IRR)netz afterall.