irrNetLite 2.1 [BETA]

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
erwincoumans
Posts: 46
Joined: Tue Oct 02, 2007 6:46 am
Contact:

Post by erwincoumans »

Is there any repository for irrNetLite (sourceforge,googlecode)?

If not, do you consider creating one?
Thanks,
Erwin
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Well it's pretty small (Just a user-friendly C++ wrapper for enet) so I didn't really consider it.

Come to think of it I should rename this to enet++.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
floppyfreak
Posts: 117
Joined: Sat Apr 19, 2008 10:14 am

trouble to compile example1 with code::blocks

Post by floppyfreak »

I try to compile example one from irrnetlite v2.0 and get linker errors.
What I have done so far is to compile irrnetlite. I got a .a file and set it on the list of project build optons / linker settings / link libraries. At the same place I added libws2_32.a from the code::blocks /lib/
What do I have to add to get the example run?
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

That should be enough. I didn't test with CodeBlocks but I did test with GCC and makefiles so it should work just the same.

I can probably give you some kind of a hint if you tell me what the linker errors were.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
floppyfreak
Posts: 117
Joined: Sat Apr 19, 2008 10:14 am

Post by floppyfreak »

BlindSide wrote: I can probably give you some kind of a hint if you tell me what the linker errors were.
That's nice

Code: Select all

..\..\..\..\irrNetLite\irrNetLite\lib.a(peer.o):peer.c:(.text+0x597)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(peer.o):peer.c:(.text+0x70b)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(peer.o):peer.c:(.text+0x999)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(peer.o):peer.c:(.text+0xc0b)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(peer.o):peer.c:(.text+0xd6e)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(peer.o):peer.c:(.text+0xe8d)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(peer.o):peer.c:(.text+0xf32)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(peer.o):peer.c:(.text+0xf7a)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(peer.o):peer.c:(.text+0x1015)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(peer.o):peer.c:(.text+0x1023)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(peer.o):peer.c:(.text+0x1031)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(peer.o):peer.c:(.text+0x12a3)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0xf3)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x38c)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x39d)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x3ae)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x675)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x755)||undefined reference to `_htons@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x77a)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0xb50)||undefined reference to `_ntohs@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0xb6b)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0xc63)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0xcaa)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0xd61)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0xd78)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0xda7)||undefined reference to `_ntohs@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0xdc0)||undefined reference to `_ntohs@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0xdf6)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0xe28)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0xe3f)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0xf19)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0xf30)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x17e4)||undefined reference to `_ntohs@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x17f6)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x1807)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x1818)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x1829)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x183a)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x18b6)||undefined reference to `_ntohs@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x1934)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x196f)||undefined reference to `_htons@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x1985)||undefined reference to `_htons@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x1994)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x19a8)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x19bc)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x19cf)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x19e0)||undefined reference to `_htonl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(protocol.o):protocol.c:(.text+0x1b51)||undefined reference to `_ntohl@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(host.o):host.c:(.text+0x318)||undefined reference to `_htons@4'|
..\..\..\..\irrNetLite\irrNetLite\lib.a(host.o):host.c:(.text+0x32e)||undefined reference to `_htons@4'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings ===|
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Those really look like you are not linking libws2_32.a correctly, those functions are found in winsock2.h.

Can you make sure that WIN32 is defined when compiling irrNetLite? The makefile I included is for Linux and doesn't have this by default. There's a chance that it's trying to use the POSIX equivalent.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
floppyfreak
Posts: 117
Joined: Sat Apr 19, 2008 10:14 am

Post by floppyfreak »

All fine now, strangely without changes. Can only have been general confusion of me, a noob in compyling foreign recources. thx for the attention.
floppyfreak
Posts: 117
Joined: Sat Apr 19, 2008 10:14 am

Post by floppyfreak »

this prog crashes

Code: Select all


#include <irrlicht.h>
#include <irrNet.h>
#include <iostream>
using namespace irr;
using namespace std;

class TEClientNetCallback : public net::INetCallback
{
    public:
        // Our handlePacket function.
        virtual void handlePacket(net::SInPacket& packet)
        {
            // Very simple callback, just echo what the server says.
            core::stringc message;
            packet >> message;
            cout <<  message.c_str() << endl;
        }
};


int initServer()
{
    TEClientNetCallback* TEclientCallback = new TEClientNetCallback();
    net::INetManager* TEnetManager = net::createIrrNetClient(TEclientCallback, "127.0.0.1");

    if(TEnetManager->getConnectionStatus() != net::EICS_FAILED)
    {
        string message;
        message="I send this for the while. Say welcome";

        // Send a packet with the message entered.
        net::SOutPacket packet;
        packet << message;
        TEnetManager->sendOutPacket(packet);
    }
    net::SOutPacket packet;
    while(TEnetManager->getConnectionStatus() != net::EICS_FAILED)
    {
        TEnetManager->update(100);
    }
    // Clean up.
    delete TEnetManager;
    delete TEclientCallback;
	return 0;
}

int main()
{
    initServer();
}

but when I use

Code: Select all

class TEClientNetCallback : public net::INetCallback
{
    public:
        // Our handlePacket function.
        virtual void handlePacket(net::SInPacket& packet)
        {
            // Very simple callback, just echo what the server says.
            std::string message;
            packet >> message;
            cout <<  message.c_str() << endl;
        }
};
(std::string instead of core::stringc)
it works fine. why?
Nox
Posts: 304
Joined: Wed Jan 14, 2009 6:23 pm

Post by Nox »

May be a bug in the overloaded method for core::stringc if there is an overload. Else you have to add such a overload ;)
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Post by polylux »

EDIT: NVM, some #ifndefs and a separate makefile target did the trick.

Firstly, what a great addon to irrlicht! :)
Secondly, I am using the JUCE framework along with irrnetlite, both making use of zlib. This apparently leads to some 'redefinitions' while linking.
So I am asking: is there a (comfortable) way to compile irrnetlite w/o zlib - or is there even a better solution?

Thanks and a happy new year,
p.
beer->setMotivationCallback(this);
Nox
Posts: 304
Joined: Wed Jan 14, 2009 6:23 pm

Post by Nox »

Hi,

there are some possible improvements for irrNetLite:
-keep zlib as an standalone project will make reuse a bit easier. Had to hack your #include "zlib/zlib.h" -> "zlib.h" and adding ../include/zlib to the projectfile would be better
-your enet version seems to be outdated
-there is a little memleak in the setUpClient method. You missed to destroy the packet under some circumstances.

EDIT:
Furthermore the clients are not really kind. They miss to disconnect themself properly from the server. This may help (has to be placed in the dtor of CNetManager):

Code: Select all

			if(mode == ENM_CLIENT)
			{
				ENetEvent event;
				enet_peer_disconnect(peer, 0);
				enet_host_service(host, &event, 0);
			}
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Thanks for the suggestions Nox, noted. I may rename this library to enet++ if I have the time for another release.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Nox
Posts: 304
Joined: Wed Jan 14, 2009 6:23 pm

Post by Nox »

Argh you arnt serious or? Then I have to rename the hole bunch of implementations >.< because I added it as irrNetLite to my networklibsbenc (but didnt upload it yet).
Brainsaw
Posts: 1176
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Hello,

I have implemented network support for my current project "marbles2" (http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=35215) and with some changes to Irrnetlite it works fine. I just have 2 issues:

- the dynamically allocated buffer makes the program crash on packet destruction. I solved it by changing the dynamic buffer to a static buffer with 4kb size (way more than I need), but maybe someone has an idea or solution.
- whenever I create a server or client for the second time the program crashes. The debugger confuses me: the crash happens when the constructor returns.

I'll try to make a small text-application that reproduces the problem. One note: I am using gcc (the one that came with code::blocks) and Irrlicht 1.6.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Is it possible that you are using different irrArray, etc implementations for irrNetLite and Irrlicht? I think this shouldn't be an issue if you have USE_IRRLICHT defined but just in case. I have heard some reports of crashes here and there so I would be interested in your test application.

@Nox PM: It's just thought for the future, I don't think I will do this anytime soon.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Post Reply