irrNetLite 2.1 [BETA]

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
mataanjin
Posts: 19
Joined: Tue May 25, 2010 3:07 am

Post by mataanjin »

zerochen wrote:hi
try to add

Code: Select all

switch(event.EventType)
{ 
case EET_GUI_EVENT: s32 id = event.GUIEvent.Caller->getID();
                                 ... break;
}
to ensure that a gui event is happend and not a key event or someting like that
yes, it solved my problem.
Thanks.

now i have another problem.
I can't create server
it shows this error

Code: Select all

irrNetLite: Error: An error occurred while trying to create an ENet server host.
and in visual studio

Code: Select all

'dada.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file
'dada.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file
Irrlicht Engine version 1.7.2
Microsoft Windows 7 Ultimate Edition  (Build 7600)
'dada.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Cannot find or open the PDB file
Using renderer: Direct3D 8.1
'dada.exe': Loaded 'C:\Windows\SysWOW64\d3d8.dll', Cannot find or open the PDB file
'dada.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Cannot find or open the PDB file
'dada.exe': Loaded 'C:\Windows\SysWOW64\d3d8thk.dll', Cannot find or open the PDB file
'dada.exe': Loaded 'C:\Windows\SysWOW64\nvd3dum.dll', Cannot find or open the PDB file
'dada.exe': Loaded 'C:\Windows\SysWOW64\powrprof.dll', Cannot find or open the PDB file
'dada.exe': Loaded 'C:\Program Files (x86)\NVIDIA Corporation\3D Vision\nvSCPAPI.dll', Cannot find or open the PDB file
'dada.exe': Loaded 'C:\Windows\SysWOW64\shell32.dll', Cannot find or open the PDB file
'dada.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Cannot find or open the PDB file
'dada.exe': Loaded 'C:\Windows\SysWOW64\nvapi.dll', Cannot find or open the PDB file
'dada.exe': Loaded 'C:\Windows\SysWOW64\wintrust.dll', Cannot find or open the PDB file
'dada.exe': Loaded 'C:\Windows\SysWOW64\crypt32.dll', Cannot find or open the PDB file
'dada.exe': Loaded 'C:\Windows\SysWOW64\msasn1.dll', Cannot find or open the PDB file
'dada.exe': Unloaded 'C:\Windows\SysWOW64\powrprof.dll'
'dada.exe': Unloaded 'C:\Windows\SysWOW64\nvd3dum.dll'
NVIDIA GeForce 8800 GTS 512 nvd3dum.dll 8.17.12.6089
'dada.exe': Loaded 'C:\Windows\SysWOW64\nvd3dum.dll', Cannot find or open the PDB file
'dada.exe': Loaded 'C:\Windows\SysWOW64\powrprof.dll', Cannot find or open the PDB file
Resizing window (640 480)
Resetting D3D8 device.
'dada.exe': Loaded 'C:\Windows\SysWOW64\mswsock.dll', Cannot find or open the PDB file
'dada.exe': Loaded 'C:\Windows\SysWOW64\WSHTCPIP.DLL', Cannot find or open the PDB file
The program '[1328] dada.exe: Native' has exited with code 0 (0x0).
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Could be a firewall or your port is already taken?

Cheers
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

Could I use Packet code for my own little networking lib? :roll:
Working on game: Marrbles (Currently stopped).
mike76
Posts: 14
Joined: Wed Jan 07, 2009 10:01 pm

Post by mike76 »

Hi,
Im trying to compile IrrNetLite (the first example) in MS Visual Studio 2008
and after adding irrNetLite.lib to my project (it's just the code from example1.cpp) it gives this kind of linker errors:

Code: Select all

1>Compiling...
1>main.cpp
1>Linking...
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(char const *)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) already defined in libcpmt.lib(locale0.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in main.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in main.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in main.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::_Mutex::_Lock(void)" (?_Lock@_Mutex@std@@QAEXXZ) already defined in libcpmt.lib(xmutex.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::_Mutex::_Unlock(void)" (?_Unlock@_Mutex@std@@QAEXXZ) already defined in libcpmt.lib(xmutex.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) already defined in main.obj
Total 29 of these..

I added the lib. directory with irrNetLite.lib in Project's Property -> Linker -> Additional Library Directories, shouldn't I ?
and tried both, with #pragma comment(lib, "irrNetLite.lib") and without.


Thank's for any help.
-mike
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Post by zerochen »

Hi,

i think that is a problem how you compile the irrnetlite.lib and your project.

try to change Project's Property -> C/C++ -> Code Generation -> Runtime Lib.

both irrnetlite.lib und your project must have there the same value

cu
mike76
Posts: 14
Joined: Wed Jan 07, 2009 10:01 pm

Post by mike76 »

Thanks you your answer zerochen, but it doesn't help :(
I can only change the Runtime Library to Multi-Threaded / with debug or DLL... and I have never played with this setting before.


I have started again with just original Irrlicht project (the "Movement" one):

- I removed the whole Irrlicht-code (the Movement-example) and copy-and-pasted the code from IrrNetLite example01.cpp in there.
- in Project Properties -> C++ -> General I added the "includes" directory of IrrNetLite (where the irrNetLite.lib file is).

At this point I am getting: LINK : fatal error LNK1104: cannot open file 'irrNetLite.lib'
so, in Project Properties -> Linker -> General ->Additional Library Directiores I added the directory to the irrNetLite.lib file.

After this, im getting these above mentioned 29 linker errors...

anyone?
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Post by zerochen »

irrlicht is compiled with multithreaded (/MT)
irrnetlite is compiled with multithreaded dll (/MD)

that is the problem just recompile irrnetlite with /MT and everything runs fine...
mike76
Posts: 14
Joined: Wed Jan 07, 2009 10:01 pm

Post by mike76 »

Thank you very much !

I have played with these multithread-Dings within my test-project (this original "Movement" example) and I forgot to rebuild the whole IrrNetLite.. :oops: after it, it works perfectly !
thanks again!

-mike
mataanjin
Posts: 19
Joined: Tue May 25, 2010 3:07 am

Post by mataanjin »

how to broadcast a message?

i want to make a lobby system, where the client will broadcast message to find all available server.
user-r3
Posts: 70
Joined: Tue Dec 07, 2010 4:09 pm

Re: irrNetLite 2.1 [BETA]

Post by user-r3 »

Hi,

I'm currently trying to implement Multiplayer in my game using irrNetLite, but using the 127.0.0.1 (like in the examples) IP to connect to a local server (no matter whether server and client are in the same game instance or in two different game instances/windows) but I receive:
irrNetLite: Error: Connection timed out. Connection failed.
mataanjin wrote:how to broadcast a message?
i want to make a lobby system, where the client will broadcast message to find all available server.
That would also be great for me, as it may deliver me a correct IP to connect :)

Thanks for everbody trying to help, I hope I don't dig out a dead thread here...

Greetings, user-r3
aburt11
Posts: 66
Joined: Sun Jan 15, 2012 10:27 am

Re: irrNetLite 2.1 [BETA]

Post by aburt11 »

Error 6 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) referenced in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z) C:\Users\adam\documents\visual studio 2010\Projects\RedNovember\RedNovember\irrNetLite.lib(CNetManager.obj)


i get this linker error when compiling my engine

here is my source:

Code: Select all

 
 
#include "main.h"
 
 
#include <irrNet.h>
 
 
int ping = 100;  //miliseconds will be calulated later
core::vector3df playerPosition;
core::vector3df playerAnimation; //no idea how to implement this yet
 
irr::c8* packetPassword = "affinityNet";
 
 
class MyNetCallback : public net::INetCallback
{
    virtual void handlePacket(net::SInPacket& packet)
    {
        packet.decryptPacket(packetPassword); //password for packet
        packet.deCompressPacket();
        
        //extract info form a packet via string
        
        core::stringc str;
        packet >> str;
 
        //3d vector packet
    core::vector3df vec;
    packet >> vec;
 
    // Here we are obtaining the last value from the packet. f32 is just a
    // typedef for float.
    f32 height;
    packet >> height;
 
    // Print the values to the console.
    std::cout << "Message: " << str.c_str();
    std::cout << " Position: " << vec.X << " " << vec.Y << " " << vec.Z;
    std::cout << " Height: " << height << " ft";
    std::cout << std::endl;
 
    }
};
 
 
MyNetCallback* netCallback;
net::INetManager* netManager;
 
 
void redNovember::initNetwork()
{
    netCallback = new MyNetCallback();
    
    netManager->setVerbose(true); //for debug
}
 
void redNovember::connectToServer(irr::c8* ipAddress,char* networkName,char* password)
{
    netManager = net::createIrrNetClient(0, ipAddress);//where for network to connect
 
}
 
void redNovember::shutdownNetwork()
{
    delete netManager;
}
 
void redNovember::networkLoop()
{
    while(netManager->getConnectionStatus()!= net::EICS_FAILED)
    {
        netManager->update(ping);
 
        //send packet crate object
        net::SOutPacket packet;
 
        //sedning strings
        packet << "some kind of fuckin message\n";
 
        //send co-ordinates
        packet << playerPosition << playerAnimation;
        
        //compress packet
        packet.compressPacket();
 
        packet.encryptPacket(packetPassword);
 
        netManager->sendOutPacket(packet);
 
    }
}
 
 
whats the problem? please help?
d3jake
Posts: 198
Joined: Sat Mar 22, 2008 7:49 pm
Location: United States of America

Re:

Post by d3jake »

BlindSide wrote:
Is this version tied to Windows and Linux? Or can it be compiled on Mac as well? Forgive me if the other one does indeed work on Mac...
In theory it'll work without a flaw on Mac, as it just uses Enet which just uses BSD sockets which are implemented pretty identically on both Unix and Mac operating systems. Googling for something like "Enet on Mac" should get you somewhere if you're stuck. This post seems relevant.
After a few year's delay: Thanks for the reply!
The Open Descent Foundation is always looking for programmers! http://www.odf-online.org
"I'll find out if what I deleted was vital here shortly..." -d3jake
byllgrim
Posts: 9
Joined: Mon May 28, 2012 12:13 pm

tons of errors

Post by byllgrim »

Why do I always write bullshit and forget about it. I think my mind is playing with me. Anyway...

I have tried lots of ways of getting this to work, and I have gotten alot of different problems.
The most common problem is LNK2019, as mentioned by other people earlier in this thread.
The IDE is visual studio express 2012.
All, or most, of the network libraries from the wiki gives me a broad variety of errors, mostly linker errors.
I cant get any of them to work :(
selujtje
Posts: 4
Joined: Thu Aug 18, 2011 11:10 am

Re: irrNetLite 2.1 [BETA]

Post by selujtje »

I'm trying to implement irrNetLite into my current project and I'm really liking it, but I've found a vulnerability which is giving me some doubts:
A client sending an unencrypted/noncompressed message will lead to an enormous memory leak(±4Gigabytes in under 10 seconds) at the SERVER!
This is quite serious as this doesn't affect the client, the one who made the mistake, but the server.Unfortunately this can be used by evil people to easily crash servers.
This leak can be reproduced by just removing lines 155 and/or line 158 of Tutorial.cpp (be careful, this might cause your computer to stop responding)
Does anyone know a way to verify incoming messages in such a way to evade a memory leak?
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Re: irrNetLite 2.1 [BETA]

Post by zerochen »

hi,

well yes i guess the tutorial.cpp shows only the basic things.
in the second example you can see if a client sends more than 20 letters he will be kicked.
so you can handle the abnormal clients like this.

a second way would be to add a function isValid and an attribute bool valid to SInPacket.
set the attr to false if in
void SInPacket::deCompressPacket() uncompress fails
and in
void SInPacket::decryptPacket(const c8 key[16]) the newSize isnt 16bit aligned

something like this:

Code: Select all

    
//in deCompressPacket()
int ret = uncompress((Bytef*)newBuff.pointer(), &destLen, (Bytef*)buff.pointer() + 4, buff.size() - 4);
 
    if(ret != Z_OK)
    {   
        valid = false;
        newBuff.set_used(0);
        newBuff.clear();
        return;
    }
 
//in decryptPacket(...)
    const u32 newSize = buff.size();
 
    if(newSize % 16 != 0)
    {
        valid = false;
        return;
    }
 
//usage
        if(!packet.isValid())
        {
            std::cout << "Wrong packet format! Kick player here." << std::endl;
            return;
        }
 
edit: dont forget to init valid with true in the constructor of SInPacket

regards
zerochen
Post Reply