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: 25th Aug 2008 00:57 Edited at: 11th Dec 2012 16:59
MikeNet (also known as DarkNet) - Latest Version: 2.0.2
DarkNet is an easy to use high performance networking plugin that is well documented with lots of demo code.

For more information see the website:
http://www.mikenetapi.net

Requirements
-DarkBASIC Pro, C++ or .NET compatible language (e.g. C#, VB.NET).
-Windows 2000/XP/Vista/7.

Bug Reporting
If you believe there is a bug in DarkNet then feel free to report it. If you find a bug you must include the following in your post:
-Your operating system.
-A screenshot of the error if there is one.

Trouble coding?
If you have trouble coding with DarkNet then feel free to ask for help on the forums or in this thread. You should consult the documentation before posting because most questions will be answered there.

Change log


Future plans
Future plans are looking very far into the future i.e. when I get more time! These are unlikely to happen any time soon.

-Packet compression.
-Web cam commands.
-Greater support for UPnP to allow applications to register themselves as UPnP devices and control other UPnP devices. Currently only port map manipulation is supported.

Attachments

Login to view attachments
draknir_
17
Years of Service
User Offline
Joined: 19th Oct 2006
Location: Netherlands
Posted: 25th Aug 2008 01:54
Very interesting, i'll be looking into this when I get to networking in my project. That is a while off though. Im going to try some demo apps now
Airslide
19
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 25th Aug 2008 01:55
Don't have time to go through much of it, but from what I read in the manual it is definitely intriguing. Being able to use TCP and UDP (at the same time?) is very interesting as well.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 25th Aug 2008 02:13 Edited at: 31st Mar 2009 19:28
Quote: "Don't have time to go through much of it, but from what I read in the manual it is definitely intriguing. Being able to use TCP and UDP (at the same time?) is very interesting as well."


Yes, you can use both at the same time.

The ARRAYinator
18
Years of Service
User Offline
Joined: 13th Aug 2005
Location:
Posted: 25th Aug 2008 05:44
Looks very Cool! Ill be checking this out tommorrow

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 25th Aug 2008 11:25 Edited at: 25th Aug 2008 11:27
Does it also make sure that the packets are delivered in the right order? (Like in multisync)

Which is a pretty crucial feature for a game developer .

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 25th Aug 2008 12:37
Yes, MikeNet does most of the work for you with TCP and UDP.

With UDP when you call mnRecvUDP only the latest packet for that client or client operation will be received. Old packets are discarded between each mnRecvUDP call.

With TCP older packets are stored and when you call mnRecvTCP you are retrieving the oldest packet that has been received since the last mnRecvTCP.

Page two of the documentation (inside the version 1.0 zip) outlines the way in which the TCP and UDP systems work.
RedFlames
16
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 26th Aug 2008 11:58 Edited at: 26th Aug 2008 11:59
When i try to compile the demos with my DBPro i get the following error:
"Failed to load DLL (2: MikeNet.dll)"
And i checked everything, its in plugin-user, and opened the DLL in notepad and found out that it might need MSVCP90.DLL and MSVCR90.DLL so i took those out of the VC++ 05 redist.-package but that doesnt help either...

Sooo... whats the problem?

(info: i got vista and i think i got the .Net Frameworks too, might check that )

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 26th Aug 2008 12:36 Edited at: 21st May 2009 14:37
I'm not sure exactly what the problem is but if you have time I'd like to walk you through a few tests 1 to 1 over MSN (I've added you).

I just tested everything on a spare laptop and it seemed to be working fine.

[EDIT]
Try the version attached to this post. Theres a chance that it will work. Simply place it in the plugins-user folder.

sydbod
15
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 26th Aug 2008 13:27
Yes ... very interesting .... I will also look into this when I get a bit of time.

Just a quick Question, Is the package an added free standing library or is it DLL based?

It is always nicer if it is a pure library as it saves one extra file to be included in a game package, and allows some tweaking to include any special features if necessary by the user.
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 26th Aug 2008 13:32
The CPP version is a free standing library.

In both DBP and CPP your projects can simply be a single exe with no extra files needed.
sydbod
15
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 26th Aug 2008 13:44
Quote: "The CPP version is a free standing library."


You have just made my day ....... I will have a play with this on the weekend ...... Thanks

I noticed there is no source code to your demo programs ..... it could be handy for people to see how you implemented your library into typical applications.

Again THANKS
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 26th Aug 2008 13:55
The source code is in the 'Version 1.0' download zip in the demos section.
sydbod
15
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 26th Aug 2008 15:50
mnSendUDPAll( bool Keep_packet , bool Block_until_sent )

I noticed there is no way in this function to send data to all users with the EXCLUSION of having the data sent back to the original sender of the data.

Basically it currently requires extra traffic to be sent to each user, as well as it will require extra processing where every user will have to check all returned UDP data, and strip and dump any data that it itself originated. It is better to pass this overhead to the server program, rather than to the client program.

Would it be possible to add an extra parameter within the mnSendUDPAll( ) function so that one can pass some identification information to this function to make it send data to all users excluding a particular user identification. If the user identification happens to be a NULL value then send data to every user.

It is just an idea that may have some merit should you agree.
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 26th Aug 2008 15:58
I'll do that for the next version, for now you can just do it manually with mnSendUDP and a loop that excludes the client that you don't want to send to.
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 26th Aug 2008 17:02
The zip attached to the original post has changed but the actual code of MikeNet has not. Here are the changes:
-Fixed a mistake in the cube world server code for C++ and DBP that was causing cubes to blip between their correct position and position 0,0,0.
-Recompiled the DBP version so that it includes a DLL that some computers do not have. If you had problems getting MikeNet to work with DBP, it should work now.

Thanks to RedFlames for helping me fix these problems.
Mr Mike
15
Years of Service
User Offline
Joined: 8th Jul 2008
Location:
Posted: 27th Aug 2008 01:55
I opened the source code for the server.cpp and I think its the same code as the client.cpp

HEYYYY YYYOOUUUUU GUUUYYYYSSSS
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 27th Aug 2008 02:04
Sorry about that; I've corrected that mistake. Re-download the zip and it should be fine.
Mr Mike
15
Years of Service
User Offline
Joined: 8th Jul 2008
Location:
Posted: 27th Aug 2008 02:50
Thanks so Much - Awesome library and fast error response

HEYYYY YYYOOUUUUU GUUUYYYYSSSS
Mr Mike
15
Years of Service
User Offline
Joined: 8th Jul 2008
Location:
Posted: 27th Aug 2008 04:39
I got another question

In the client script if I just keep it at just a simple shape, it will work fine. But how can I change it so it loads a .3ds model for the player model?

HEYYYY YYYOOUUUUU GUUUYYYYSSSS
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 27th Aug 2008 12:31 Edited at: 27th Aug 2008 12:33
I don't have any 3ds, but you can just change the file name in the code to the name of your object.

This is the simplest way of using models instead of cubes. Essentially you just use dbLoadObject instead of dbMakeObjectCube. This is client code, the server does not need to be changed:


Screenshot:
Tav
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location:
Posted: 27th Aug 2008 20:09
when trying to build the example code, I get this error
Any help?

Thanks
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 27th Aug 2008 22:37 Edited at: 27th Aug 2008 23:45
Did you set the project up as explained in page 9 of the documentation?
RedFlames
16
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 27th Aug 2008 23:09 Edited at: 27th Aug 2008 23:48
It looks like i cant send strings with TCP, please come online at msn

Attachments

Login to view attachments
Mr Mike
15
Years of Service
User Offline
Joined: 8th Jul 2008
Location:
Posted: 28th Aug 2008 00:50 Edited at: 28th Aug 2008 01:29
I am so close to integrating my game with MikeNet but how do I detach the object from the camera so that the object moves and the camera follows? Right now no matter where I position the camera its always inside the object. As of now Im using the client.cpp as a base code.

HEYYYY YYYOOUUUUU GUUUYYYYSSSS
Ben Johnson
16
Years of Service
User Offline
Joined: 6th Jul 2007
Location:
Posted: 28th Aug 2008 01:48
If I use multisync to hold a seperate connection will this interfere or cause any problems between itself and Multisync?
Mr Mike
15
Years of Service
User Offline
Joined: 8th Jul 2008
Location:
Posted: 28th Aug 2008 02:40
Here is a video of my problem. http://www.youtube.com/watch?v=YEJODynwMgs

HEYYYY YYYOOUUUUU GUUUYYYYSSSS
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 28th Aug 2008 03:24 Edited at: 28th Aug 2008 03:25
Quote: "If I use multisync to hold a seperate connection will this interfere or cause any problems between itself and Multisync?"

I'm not sure, you can always give it a go and see if it works.

Quote: "I am so close to integrating my game with MikeNet but how do I detach the object from the camera so that the object moves and the camera follows? Right now no matter where I position the camera its always inside the object. As of now Im using the client.cpp as a base code."

I'm not sure exactly what the problem is but I'll try my best to help you figure it out . By the way, I love the video name "Askin Mike P for help lol"

It sounds to me like you should be sending/receiving the position and angles of the player's object. The client demo code sends the player's camera positions/angle and since your dealing with a 3rd person view, this is not the position that should be sent.

The problem also seems to be that the client is repositioning its own object which is actually visible in your code. For this reason, you should ensure that if the client receives a request to reposition its own object, it ignores this request.

Let me know if the above made sense or helped, it may not have :

Quote: "It looks like i cant send strings with TCP, please come online at msn "

I'm investigating this right now, but will probably carry on in the morning. I'll post details of the problem at some point in the next few days.
Mr Mike
15
Years of Service
User Offline
Joined: 8th Jul 2008
Location:
Posted: 28th Aug 2008 04:16
Basically forget what I said earlier.

Im trying to change the packets from sending the camera position to the server to sending the Object Position to the server.



However it wont let me compile because its an undeclared identifier. Do you know how I could show the code the iPlayer identifier from this code from earlier?



Sorry if that question wasn't clear I'm extremely new to online programming.

HEYYYY YYYOOUUUUU GUUUYYYYSSSS
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 28th Aug 2008 04:30 Edited at: 28th Aug 2008 04:31
Bug Fix
Good news! Despite being extremely tired, I have fixed the following bug identified by RedFlame: if performing mnGetString() on a string that is not at the start of the packet, an empty string is returned. This bug affected both the C++ and DBP version of MikeNet.

You can download the fixed version in my original post which is version 1.0.1. Let me know if it all works, being this tired its not impossible that I've made a mistake somewhere .


Mr Mike, before I goto bed I'm going to try and help you solve your problem
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 28th Aug 2008 04:41 Edited at: 28th Aug 2008 04:42
@ MrMike
If I understand you correctly, what you are trying to do is work out the client's client ID so that you can ignore packets destined to try and reposition its object.

In the original demo client code here:


is where the client finds out what its client ID is. You can store this in a global variable and use this instead of iPlayer in:



If the following isn't too difficult for you I would recommend doing this on the server side instead of using the 'ignore packets concerning me' method. Instead of using mnSend***All, create a loop that uses mnSend and excludes the client whom the original data is from.

I think I'll add in a command to do this automatically tomorrow morning, if I have time.

Hope this helped
Mr Mike
15
Years of Service
User Offline
Joined: 8th Jul 2008
Location:
Posted: 28th Aug 2008 04:44
Ok I'll try that good night Mike P

HEYYYY YYYOOUUUUU GUUUYYYYSSSS
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 28th Aug 2008 16:03 Edited at: 28th Aug 2008 16:04
Update v1.0.2
I've added a parameter to the mnSendAll commands that allows you to specify a client to exclude from the send list. This means essentially that you are telling MikeNet to: "Send to all clients except one". If you don't want to exclude a client, set this parameter to NULL. The documentation and cube world demo code have also been updated.

You can download the new version from the original post of this thread.

Let me know if you have any problems with the new version
Tav
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location:
Posted: 28th Aug 2008 16:04
Still have the LINK errors even with the ignore libs as told on page 9. :s
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 28th Aug 2008 16:07
Can you attach the project folder in a zip please and I'll have a look at the project settings as soon as I can and get back to you on what the problem was. Delete anything in the debug/release folder so that the file size isn't too big.
RedFlames
16
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 28th Aug 2008 16:26
Quote: "Good news! Despite being extremely tired, I have fixed the following bug identified by RedFlame: if performing mnGetString() on a string that is not at the start of the packet, an empty string is returned. This bug affected both the C++ and DBP version of MikeNet."

Well maybe the bugfix is only included in 1.0.1, but in 1.0.2 its still not working... (only if i send the string first, thats ok for now too )

Tav
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location:
Posted: 28th Aug 2008 16:31
Here it is it's just part of your example to see if it works.

Attachments

Login to view attachments
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 28th Aug 2008 17:21 Edited at: 28th Aug 2008 17:56
@ Tav
Here are the settings that I changed to get it to work:

Linker | Input:
-Additional Dependencies: MikeNet.lib WS2_32.lib

C/C++ Preprocessor:
-Pre-processor definitions: Removed "WIN32;_DEBUG;_CONSOLE"
-Code generation: Multi-threaded

Attached is the working version.

Attachments

Login to view attachments
Tav
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location:
Posted: 28th Aug 2008 17:29 Edited at: 28th Aug 2008 17:33
Thanks Mike!
Lol, attached a diffrent project to my reply ^^, sorry. But i'll try it on the original.
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 28th Aug 2008 17:42 Edited at: 28th Aug 2008 17:43
@RedFlames:
I ran the code you attached earlier when reporting the return string bug and it seems to work fine for me with version 1.0.2:


Is it possible that the new version hasn't installed properly? See if mnSendAll commands have the client id to exclude parameter.
Tav
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location:
Posted: 28th Aug 2008 17:44
Tried it on the right one, didn't work included the right project this time xP

Attachments

Login to view attachments
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 28th Aug 2008 18:00
The problem is that you are trying to use console mode with dark gdk. Do the following:
-Change "void DarkGDK ( void )" (line 17) to "void main ( void )"
-Delete the line "#include "DarkGDK.h" (line 3)
Tav
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location:
Posted: 28th Aug 2008 18:02
Ow, Totaly missed that. Thought it was something with the project settings, hehe, thanks again :d.
RedFlames
16
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 28th Aug 2008 18:37 Edited at: 28th Aug 2008 18:39
Quote: "Is it possible that the new version hasn't installed properly? See if mnSendAll commands have the client id to exclude parameter."

Ooooh i just found the problem: Although the Dll was installed, (and integrated into the Exe, of course)
the old MikeNet.dll, which was in the same dircetory interferred with it... (new parameter was there, but it still used the old one or what ever )
The Dll was there because i had tested Excluding all DLLs from the Exe via "Dark Explorer", but why should that affect the Exe which has the new version inside itself

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 28th Aug 2008 20:18
I have no idea . This shouldn't be a problem though, just have to remember to keep old versions of MikeNet away from the exe.
sydbod
15
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 29th Aug 2008 10:21
@ Michael P

When mnStartServer() gets an empty string pointer for its "LocalIP" to force it to find and select a working interface IP, and then after the server is running and one uses the mnGetLocalIP() to try to find what IP the server has chosen, the returned IP is always 0.0.0.0 rather than the actual interface IP.

A correct IP gets chosen by the server, it is just that the mnGetLocalIP() function will not return it, so one is not certain what network interface was chosen as default.

Only a minor fault ..... otherwise things are looking very good on this side.

Of secondary note ... the library can not be used in DEBUG mode on my machine ... it only works when release mode is selected. I assume that is normal, and if it is, it may be worthwhile (if it has not been done)to mention it in the notes to save some of the others asking about it.

Thanks again.
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 29th Aug 2008 21:08 Edited at: 30th Aug 2008 11:21
Thankyou for reporting this.

It seems that the function mnGetLocalIP uses (getsockname) does not work in this situation. Here is a quote from the documentation that explains why it does not:

Quote: "The getsockname function does not always return information about the host address when the socket has been bound to an unspecified address, unless the socket has been connected with connect or accept (for example, using ADDR_ANY)."


I don't know of any other way of finding the local IP and so I have updated the documentation to take this into account. It now says that the command will not work in server state when MikeNet finds an IP.

MikeNet does work in debug mode as well as release mode (for me anyway). One of the project settings that is not unique to debug mode must be conflicting with MikeNet. If you want to get MikeNet to work in debug mode, you could try changing each project setting for debug mode to be the same as release mode, except the ones necessary for debugging until it works. You can also have a look at the project settings of the attached cube world server project.

Attachments

Login to view attachments
sydbod
15
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 31st Aug 2008 13:59 Edited at: 31st Aug 2008 14:01
@ Michael P

Thanks for that.

Have found the Debug Compilation problem.

If it has not been done, it may be worthwhile to add this to the documentation.(I really should read the documentation more thoroughly)

Under default conditions "Project Properties" -> "Configuration Properties" -> "Code Generation" -> "Runtime Library" will have the following entries.

In Debug Mode = Multi-threaded Debug(/MTd)

This will have to be changed to:

In Debug Mode = Multi-threaded(/MT)

So it looks like Debugging will not be properly available, but that is of no real relevance because the quality of your DEMO code makes it almost impossible for people to make a mistake in that area.
They will just have to debug their game code first and then ADD your almost foolproof demo code or a modified form of it as a last step.

In my project I will add code for the server to take values from a "Server.INI" file for default settings, so that the getsocketname() limitation will also not be a problem.

This is one of the easiest networking libraries that I have had the pleasure to work with, and is a great addition to DGDK. Congrats, I will put it to good use also.
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 1st Sep 2008 23:02
Future plans
-Allow multiple connections and multiple server hostings to be possible at the same time within the same application. Essentially this would allow you to run multiple instances of MikeNet at the same time within the same application.

-Add commands that will aid streaming of sound content directly from the microphone. This would make a Ventrilo/Team speak/Skype type of application possible.
sydbod
15
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 2nd Sep 2008 06:10 Edited at: 2nd Sep 2008 07:06
@ Michael P,

It looks like there is a problem with clients that are going through Routers (NAT). (or at least that is what it looks like on my testing setup)

As I don't have your source and am not certain if you have take this sort of connection into account, could you please confirm if the following is happening with your package.

SERVER:
It starts up and looks at a particular TCP port and a particular UDP port.
All server machines normally have port forwarding configured within the routers so that the same port number for the relative TCP and UDP port on the server is matched to the same port number on the internet side.
This port forwarding will at the same time open a permanent link between the internet ports and the server ports.


*****TCP TRAFFIC*****
CLIENT:client starts up and sends TCP traffic to the server TCP port. This opens the link for bidirectional traffic from the internet port to the server machine port)
SERVER: Logs the client IP number and the TCP port number that the traffic is coming from.

BOTH: negotiate with each other where the server sends to the logged client TCP port.

(there can be no assumption made about what the client TCP port number will be, it has to be captured from the traffic)

****UDP TRAFFIC****

The client MUST be the first program to send any UDP traffic.

CLIENT: client send any sort of traffic to the server UDP port. The UDP port from the client software will be mapped to a random UDP port on the internet side of the Router. This opens the path for bidirectional UDP traffic through the router between these 2 ports.

NOTE: ( just because the client may be sending both TCP and UDP traffic from the same interface port number ...... does NOT mean that the port used on the internet side of the router for both the TCP and the UDP traffic will be the same. In all probability the port numbers for each of these data connections will be different on the internet side.)

SERVER: It must now log the port number that this first UDP traffic is coming from for the particular user ID.

The server will now have the following information.
User ID
User IP
User Traffic TCP port number
User Traffic UDP port number

The server may only now send UDP traffic to that particular client.


Under no accounts should it be assumed that the "User Traffic TCP port number" and the "User Traffic UDP port number" will be the same.


If the above procedure is followed then there should be no problems for clients behind routers.


If you library already does this then please let me know as I will have to look further into my test setup and see what is going on.

Login to post a reply

Server time is: 2024-03-29 15:26:26
Your offset time is: 2024-03-29 15:26:26