Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Program Announcements / MikeNet - Multiplayer Plugin

Author
Message
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 20th Mar 2013 02:05 Edited at: 20th Mar 2013 02:06
Quote: "Edit: I should also mention that this happens even under the simplest circumstances; in total 4 packets of at most 64 bytes each are send between ONE client and the server, so it wouldn't be that any memory is allocated on an as-needed basis under long extents of time."

MikeNet hardly ever allocates memory on the fly, everything is allocated during instance initialization and reused. The reason for this is that memory allocation and deallocation are expensive whilst reusing and copying blocks of memory is comparatively cheap. Everything that is allocated in instance initialization (mnStartServer, mnConnect, mnStartBroadcast) is deallocated by mnFinish in order to prevent memory leaks; we could hold the memory in a memory pool, but I never implemented that.

The 4 important values which determine memory usage are:
- Maximum number of clients when setting up server.
- TCP buffer size on mnSetProfileBufferSizes (default 1024 bytes).
- UDP buffer size on mnSetProfileBufferSizes (default 1024 bytes).
- UDP mode.

If you set maximum number of clients to 50 then there will be at least 50 TCP buffers and 50 UDP buffers created so you are looking at about 100kb (actually it will be more because there are additional buffers for TCP).

Also note, that UDP modes per client and per client, per operation are particularly good at eating up memory.

If you have a maximum number of clients set to x, then in per client mode x*x UDP buffers will be created. If you also have y operations then x*x*y buffers will be created. CATCH_ALL and CATCH_ALL_NO don't incur additional overhead so it would be x buffers only.

It all boils down to CPU time being prioritized over memory consumption in MikeNet. So we allocate fixed memory at startup and do not allocate or free anything for the life time of the instance, even if we only end up using 1 byte of the 1024 allocated (for example).

The big advantage of this design is that client joining/leaving is almost completely free! because the area of memory is already reserved ready for them to jump into, and when they leave it is kept for the next client.

Quote: "I can get that cleaning up all the UDP message queues might take a while, but I find it weird that deallocation takes (significantly) longer than the allocation at startup."

What OS are you using? I noticed this a while ago and ran some tests; I think Microsoft sorted this post XP. Interestingly deallocation is significantly cheaper from Windows 7 (maybe Vista) onwards.

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 20th Mar 2013 02:18 Edited at: 20th Mar 2013 02:19
Interesting points.
I agree that it is probably the design choice to be preferred.

I am in fact using the PER_CLIENT UDP mode, so that would explain the experienced time complexities, startup is still achieved in less than a second with 10 000 x 10 000 x 8 buffers then though. One would think finding a free memory block to allocate should be slower than just marking one as free again (granted I don't know how memory allocation is actually done but I would assume it works something like that).

Quote: "What OS are you using? I noticed this a while ago and ran some tests; I think Microsoft sorted this post XP. Interestingly deallocation is significantly cheaper from Windows 7 (maybe Vista) onwards."

Funnily enough I'm using Windows 7 (professional, SP1).


"Why do programmers get Halloween and Christmas mixed up?"
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 20th Mar 2013 20:10
Quote: "The memblock commands in DBP wrap around GetString"


Interesting; glad you mentioned that; that would make things much easier. I just need to figure out a way to determine the data format of the memblock as you say. Thanks.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 15th May 2013 15:10
antondbpro, please post code.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 15th May 2013 23:44
You joined today and have uploaded an executable with no explanation...

Post some code or I will not help you.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th May 2013 02:58
Probably a fake account I think.

I have error, download this random file!

"You're all wrong. You're all idiots." ~Fluffy Rabbit
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 16th May 2013 06:20
He is also on this thread:

http://forum.thegamecreators.com/?m=forum_view&t=145404&b=8

Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 21st Jul 2013 19:14 Edited at: 21st Jul 2013 19:16
Hello Mike

I can't run my DBPRO application using a .NET process due to the following error message in the DBPRO application: "Could not find function 'Start' in 294:MikeNet.dll".

Two ways in which the DBPRO application was started by the VB.NET application was with the Shell(filename) and Process.Start(filename) procedures.

I am assuming this problem exists due to the .NET application having a reference to the .NET version of MikeNet; which may be overriding the DBP reference when run by the .NET process.

My temporary work around is to launch a DBP app which launches the MikeNet DBP app. The problem now is shutting down all applications when the master .NET application shuts down; I have no process reference to work with so the programs have to guess when to shut down themselves.

Any suggestions for getting both MikeNet references to work seperately whilst running processes directly from the master process?

Do you need a sample program?

Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 21st Jul 2013 19:41
OK: Solved.

The .NET program was overriding the working directory of the DBP application. I have to specify this working directory to prevent the conflict.

Gunslinger
17
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 13th Aug 2013 04:10 Edited at: 13th Aug 2013 04:11
Works perfect, thank you very much!
Push To Talk \o/
Awesome.

Would buy it if i would've money. Well, maybe later!

(Open Source Version compiled & DarkGDK)
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 1st Oct 2013 02:38
Michael P,

Dang it takes a while to find this thread...

Any news on .NET 4.5+ support? For C# of course

Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 2nd Oct 2013 22:42
Please educate me; what would .NET 4.5 support do for MikeNet to improve it? Just curious to learn.

GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 2nd Oct 2013 22:55 Edited at: 2nd Oct 2013 22:55
@Michael:

I randomly get this error when I close my application. I am using MatrixUtils "set message callback" to capture when someone closes the window, and it runs a bit of code that, if the network connection is connected or connecting, calls mn finish. It does that fine, but then later when I call end, this pops up. I prefer error mode 1, so I turn off both 2 and 3, so I shouldn't be getting popups at all anyway.

I also tried looking at the source for NetCompletionPortFunction.cpp on your Github, but it kept timing out.

Any suggestions?

I would post the project, but it is massive. I will let you check that particular function for problems before I try making a small, test project.



Attachments

Login to view attachments
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 3rd Oct 2013 01:38 Edited at: 3rd Oct 2013 01:40
Hi guys, good to see people still using MikeNet


Regarding .NET 4.5 - I think with .NET if you use 4.5 of the framework you can't use DLLs built for older versions so they need to be rebuilt.

I don't have alot of time at the moment but in theory it should just be a case of recompiling, but it depends if the visual studio C++ compiler supports this (which it probably does). You can do this yourself if you pull it from github; or if you really want me to do it, I will see if I can find some time in the next couple of months.

@ GIDustin
There are a number of edge cases for errors which occur in threads; these can't easily be passed to the main thread using the other error systems so they always trigger a message box. In theory they should never be triggered but either you are corrupting the memory somehow or there is a bug in MikeNet!

A couple of thoughts...

If you are in the middle of the connection process and you call mnFinish(-1) that might cause an issue (this would be a bug in MikeNet). I don't think I properly tested that case. Is there a cancel connection command?

In DBP before the application terminates mnFinish(-1) is called. I designed it so that mnFinish(-1) can be called any number of times without side effect (so subsequent mnFinish(-1) do nothing) but there's a chance that this isn't the case. So maybe don't call mnFinish(-1) yourself, let it be called when the application is terminating.

There is also a chance that the 'set message callback' function you are using (or something else) is conflicting. The completion port uses alot of windows callbacks so any conflict might cause an issue there.

If you can replicate it in a standalone bit of code then I will debug and fix, but otherwise this is a tough one.

GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 3rd Oct 2013 02:06
@ Michael

Without your plugin, 75% of my projects die. Don't ever stop supporting it! Frankly, I think it is under priced.

Anyway, I call mn finish 0 as 0 is the only instance I am using. I will change to -1 and see what happens over the next few days. I do know that I have seen it while already connected, and not while in the process of connecting. After changing to -1, I will try a myriad of ways to crash the program and let know what I find.

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Oct 2013 09:03
Michael P would love it if you could get it compiled in the coming months

I need it for C#.NET 4.5+ and C++

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Oct 2013 09:04
Also, I am using VS2012 and soon 2013...

GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 3rd Oct 2013 18:31 Edited at: 3rd Oct 2013 18:34
@Michael

I changed my mn finish 0 at the end of my program to mn finish -1 and I still randomly get that error. If I open, and then close the application a dozen times, it will throw this usually at least once.

I thought you might be on the right track with the "set message callback" thing. When my program receives "WM_CLOSE" from the system, it calls "mn finish" before it returns a value back to the system. Therefore, it is in the process of responding to a callback when your program does what it does. I have instead made it so that WM_CLOSE sets a flag, responds back to the system, and then on the next loop it runs mn finish and ends the program. However, that didn't prevent the error from occurring either.

I then did another test where I detect a keypress of F1, and if found, call end immediately. I still randomly got that error when ending the application using that method. For my last test,
I disabled message callbacks completely, and the error still occurred.

I then made the attached test project, stripped down versions of my server and client, and I got the problem on the third try. You might need Matrix for some of the logging commands...

Any other suggestions?

Edit: Instructions for the attached project in Code:
1: Run Server
2: Open Client
3: Close client using window close button
4: If crash, hooray!
5: goto 2

Attachments

Login to view attachments
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 3rd Oct 2013 23:34
So I tried for about 10 minutes opening and closing many times and could not replicate the issue. I used the executables in your attachment.

One note is that mnFinish is designed to be used only in the same thread as every other networking command, so if you are calling mnRecv (for example) and mnFinish at the same time from different threads then it may crash. But from what you've said I think your example is doing it all from the same thread.

Strange that I can't replicate it, maybe something on your computer is interfering? I am on windows 8, what OS are you on?

Can you maybe write a script to run and kill the client so I can just run it and leave it running for an hour and see if it crashes?

See attached screenshot of server.

Attachments

Login to view attachments
GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 3rd Oct 2013 23:42
I am using Windows 7, 32 bit. Using the EXE in my attachment, it threw the error after the 5th time. Screenshot attached.

Do you have the full Matrix plugin suite installed? If so, I can make the server app continuously load and kill the client.

Attachments

Login to view attachments
GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 3rd Oct 2013 23:55
And a second post to attach the new project. The server will open and then close the client every 3 seconds.

Would appreciate if others could also run and see if they get the error as well. I have not yet seen it on windows 8, but we run XP and 7 throughout our network and I see it on those OSes.

Attachments

Login to view attachments
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 4th Oct 2013 00:12
I can install whatever you want so long as its free. But would prefer an executable which I can run stand alone. I want to rule out it being something specific to your system.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 4th Oct 2013 01:41
I left it running for 1hour 20mins and no errors. I suspect some software on your computer is conflicting e.g. anti virus.

Not alot I can do unless I can replicate myself!

GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 6th Oct 2013 07:14
@Michael,

I will try to run some more tests and see what I can find. In the meantime, is there any way to completely disable those error messages? I only ever get them when the program is closing, and so they aren't particularly informative, just somewhat annoying.

The blizzard in South Dakota has me stranded at home and unable to go to work, where apparently the sprinkler system went off and flooded the place. So it might be awhile before I get back to any coding.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 6th Oct 2013 18:08
It would require a small code change. I can do this for you and email it to you if you like.

Hope you get through the blizzard okay!

GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 16th Oct 2013 02:53
Quote: "It would require a small code change. I can do this for you and email it to you if you like."


That would be great. I will try to find some commonalities between the PCs to see if I can narrow it down, but it would be nice to have a plan B in case I cannot figure it out.

Email address can be found in my profile.

Thanks!

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 17th Oct 2013 01:16
Okay - will try to do this next week, please email me if I forget!

GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 28th Oct 2013 01:44
@Michael;

Just a friendly reminder to make that version with no error popups. I also left that automated program running on my two home computers and it did not crash at all on them. It seems to just be random work computers, so hopefully I can track down the commonality between them one day.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 31st Oct 2013 00:48
I've emailed you the DLL.

If you have any issues with the DLL drop me an email.

Qqite
14
Years of Service
User Offline
Joined: 28th Feb 2010
Location: Florida, U.S.
Posted: 6th Nov 2013 22:59 Edited at: 6th Nov 2013 23:01
Hello again Michael! Long time no see

So I've become a Unity user and loving it. I want to integrate your DLL in with the C# scripts but I keep getting compile errors. I did a Google search and it seems someone found out that your library uses a different version of .Net which interferes (or something like that, I'm still rather new to C#).

Ref: http://forum.unity3d.com/threads/31796-Darknet

My goal is to use your library as a Client in C# in Unity and use good ol' classic C++ as the server (no Unity).

So my question is: Do you have any experience with importing your DLL into Unity? If not, what would you guess needs to be done to get them to cooperate?

P.S. I know there are plenty of Network engines for Unity but I want to make one good project with Mikenet mainly for the C++ server side. I want to add the project to my empty resume to potentially get me a basic Software Based Internship somewhere (I'm an Engineering Sophomore in College).

Ventures of the worlds around us are limited only by our imagination.
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 7th Nov 2013 00:37
There was a big push to get this working a few years ago which failed...

I can't remember the specifics but will read over it and see if anything has changed.

The thread:
http://forum.unity3d.com/threads/31796-Darknet

Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 25th Dec 2013 19:22
Quote: "Hi guys, good to see people still using MikeNet "

I love it and use it much. Your continued support through the forum is very much appreciated!

There... had to say it

Regards Sph!nx
www.mental-image.net
Qqite
14
Years of Service
User Offline
Joined: 28th Feb 2010
Location: Florida, U.S.
Posted: 28th Jan 2014 00:57 Edited at: 28th Jan 2014 01:00
Hello, me again.
It seems unity still uses .Net 3.5
Is there any way you could compile a dll with 3.5? It would be greatly appreciated. Thanks.

Edit: Unless, of course, you are using .Net 4 in Mikenet now. Which would not make this readily possible :/

Ventures of the worlds around us are limited only by our imagination.
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 1st Feb 2014 17:12
Several people have asked for a 3.5 DLL over the years.

I spent a while trying to do this (see the Unity thread) but ultimately failed. Visual studio forces it to .NET 4 and there doesn't seem to be way to override this.

You could try using VS 2008, this might work; but I don't have time at the moment to play around with this. Do let me know if it works though and I'll add in whatever you do to the repo.

GreenDixy
16
Years of Service
User Offline
Joined: 24th Jul 2008
Location: Toronto
Posted: 22nd Mar 2014 05:30
When I compile mikenet in 2013

Gives me this message. Kinda new at this.



This line is one of them when you click on one of the messages above



.:: Http://DeanWorks.Ca ::.
My software never has bugs. It just develops random features.
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 22nd Mar 2014 14:14
Its a false warning - I explained earlier in this thread somewhere the details of this.

Basically, this warning shouldn't show for pure abstract functions because there is no dominance, it doesn't matter which is inherited since there's no function implementation.

So you can safely ignore that warning.

Login to post a reply

Server time is: 2024-11-21 15:19:35
Your offset time is: 2024-11-21 15:19:35