Jump to content
Leadwerks Community

Recommended Posts

Posted

It seems this comes up from time to time but does anyone have a basic network example they could share? I'm stumped right from the start. All I'm trying to do is send integers back and forth from host to client and reverse.

 

Even putting this in

 

THost host;
host = CreateHost(0,80,2);

 

results in:

error LNK2019: unresolved external symbol "unsigned char * __cdecl CreateHost(int,int,int)" (?CreateHost@@YAPAEHHH@Z) referenced in function _main

 

What does that mean? Any help would be really appreciated!

Posted

LNK2019 means that CreateHost has been declared, but the linker cannot find where that function is defined.

 

As I don't use the Leadwerks networking commands, I wouldn't know what you would need to include to fix it

LE Version: 2.50 (Eventually)

Posted

I added netwerks.cpp and it compiled then crashed but thank you both! That's one step forward. :)

(I was under the impression, by the way, that including netwerks.h would cover this but it seems I was wrong.)

Posted

You need initialize Netwerks also using InitializeNetwerks() and at the end terminate it using TerminateNetwerks().

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Posted

Thank you. Added it. Still crashed. But now the console says that netwerks.dll failed to load. I tried to find the dll but it doesn't seem to come with the program. Very odd.

 

On a side note, for those like Lumooja who seem to be familiar with this: how did you learn? Is there a resource outside of the wiki and related documentation that I'm missing? Nothing mentions functions like InitializeNetwerks() and TerminateNetwerks() that I could find, for example.

Posted

Networking commands were removed from the DLL in the latest SDK from what I recall.

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Posted

If this is the case, that would make sense as to why the linker can't find the code definitions

 

So I guess the solution for this issue is the usual: use a third party lib like RakNet

 

 

Edit: Or, you could define it yourself...

 

THost CreateHost(int ip, int port, int players)
{
   printf("Thank you Mumbles, you made the linker error go away!\n");
   return NULL;
}

 

Of course, you can't do any networking with that - but it should make the linker error away... ;)

LE Version: 2.50 (Eventually)

Posted

It seems Josh forgot to include netwerks.dll in the 2.32 installer, but you can get it from 2.30 or 2.31.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Posted

Good thought. I haven't updated in a bit though so I think I actually have 2.30 (at work now so I can't check) so it seems it hasn't been included in some time. That's actually what I was trying to PM Josh about (see Recent Status Updates on main Forum Page). Darn. enet is undocumented. RakNet is a bit complicated for me. Leadwerks networking is undocumented and kind of half broken. Bleh.

 

Thank you for everyone's help though. It truly is appreciated more than you know. ;)

Posted

Alright! Finally getting up and running on the netwerks front. Josh was kind enough to update the SDK to include the DLL. I can now get it running but it crashes on TerminateNetwerks(), after user presses ESC. If I comment out that line, the program exits properly.

 

At this point my program is super simple.

 

#include "engine.h"
#include "netwerks.h"

int main()
{
if(!Initialize()) return 1;

InitializeNetwerks();

RegisterAbstractPath("D:/Programming/Leadwerks Engine SDK");

// Set graphics mode
Graphics(320,40);

// Create framework object and set it to a global object so other scripts can access it
TFramework fw = CreateFramework();

// Set Lua framework object
SetGlobalObject("fw",fw);

// Set Lua framework variable
BP lua=GetLuaState();
lua_pushobject(lua,fw);
lua_setglobal(lua,"fw");
lua_pop(lua,1);

// Get framework main camera
TCamera camera = GetLayerCamera(GetFrameworkLayer(0));
PositionEntity(camera,Vec3(20,60,-50));
RotateEntity(camera,Vec3(45,0,0));

TLight light=CreateDirectionalLight();
RotateEntity(light,Vec3(45,45,45));

THost host;
host = CreateHost(0,80,2);

SetStats(0);

while(!KeyHit(KEY_ESCAPE))
{
	UpdateFramework();
	RenderFramework();

	DrawText(0,0,"Host Keys: ");
	DrawText(0,20,"Peer Keys: ");

	Flip(0);
}

exitapp:
TerminateNetwerks();  // Crashes here if this line isn't commented out
return Terminate();
}

 

I removed the error checking to make things as easy as possible.

 

Any ideas why it would crash?

Posted

You need need to initialize netwerks before the engine, and terminate it after the engine.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Posted

You need need it initialize netwerks before the engine, and terminate it after the engine.

 

Really? I thought it relied on the entity system...

LE Version: 2.50 (Eventually)

Posted

Networking is not only for entities, it's basically just a hack to exchange data because not all computers are tied together via the same RAM memory.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Posted
:)

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Posted

Networking is not only for entities, it's basically just a hack to exchange data because not all computers are tied together via the same RAM memory.

 

I didn't say I thought it was just for entities. I meant I thought it used the entity messaging system as a way of transporting data around. But in any case, you knew the answer to the question. Have you been playing around with it. Or was it just part of your infinite knowledge?

LE Version: 2.50 (Eventually)

Posted

It's only esoteric knowledge, since I wrote also the netwerk headers and noticed this behaviour while testing it :huh:

The reason is probably somewhere deep inside the way how BlitzMax's garbage collection works, and it will be fixed when LE 3.0 is written in C++.

Garbage Collection languages allow so many hidden bugs that you can never know how many bugs your program still has, since it doesn't crash immediately but completely randomly depending on time.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Posted

Have you seen the tutorials? They're hardly brief, easy-to-understand-at-first-glance snippets. Even though they're broken up into what should be small segments, like "Creating Packets," each page is stuffed with rules of things you must and can't do to make sure your program works. Hardly an indication of a friendly engine.

Posted

I have seen the tutorials. I have used them to get networking working. If I'm able to get it working anyone can, trust me. You will get more out of RakNet than LE's current networking API.

 

I thought RakNet was overwhelming at first too, but one you see how BitStreams work, it's very simple actually.

Posted

Rest assured that RakNet is a close second on my list. If I crash and burn with Netwerks, it is where I'll turn. I've looked at enet as well (what I understand Netwerks to be built on top of) and though I like its documentation the most of the three, it doesn't seem to have a visible community behind it (does it even have a forum?).

  • 1 month later...
Posted

LNK2019 means that CreateHost has been declared, but the linker cannot find where that function is defined.

 

As I don't use the Leadwerks networking commands, I wouldn't know what you would need to include to fix it

 

So what do you use?

If it's not Tactical realism then you are just playing..

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...