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
*****VERSION 2.0.2*****
Bug fixes:
- Fix bug where mnDNS failure can cause errors later on.
- Fix bug where starting threads (threads are started in module initialization and when encryption/decryption first occurs) can cause unexpected errors.
- Fix bug where UPnP module can fail or trigger errors in some circumstances.
Changes:
- Visual studio 2012 support for .NET and C++ users.
- 64 bit support for .NET, C++ (VS 2010/2012) and DLL users.
- Improved demo code.
- TCP_RAW mode to allow direct TCP communication, useful for HTTP.
*****VERSION 2.0.1*****
Performance improvements.
Introduced memory recycling and memory limits.
*****VERSION 2.0*****
New features in this version include:
Open source.
New detailed documentation of all commands and classes (including internal ones).
C++ users have access to internal classes which are easy to use and very flexible.
Very stable and well tested, with unit, sub system and system testing.
Multi threaded encryption and decryption, which distributes the load very efficiently.
Asynchronous encryption and decryption.
Instance profiles to make managing multiple networking instances easier.
Improvements in speed across the board.
64 bit compatibility (not included yet, but on its way. This update includes the necessary changes to make this possible).
Normal DLL for use with languages that can call DLL functions such as Unity 3D.
Existing users must adhere to the following changes:
Many commands e.g. mnGetTCPRecvSize have been renamed mnGetRecvSizeTCP, the rule is that TCP and UDP must be at the end of the command name.
Instance profiles must now be used so instead of using mnSetLocal to change the local address of a single instance, mnSetProfileLocal must be used to change a profile's local address. This profile is then passed to instances when they are first being setup.
When adding client ID or operation ID for use with UDP modes 'per client' and 'per client, per operation', mnAddSizeT must be used instead of mnAddInt.
When receiving data in UDP modes 'per client' and 'per client, per operation' the client ID and operation ID are included in received packets, but the cursor is positioned after them.
You no longer poll on individual NAT operations, you poll only on the last NAT operation.
You no longer have to use mnStartUPnP or mnFinishUPnP (these commands have been removed).
mnGetPhysicalCPU has been removed.
Sound profiles have been introduced; sound profiles change the format of sound i.e. samples per second, bits per sample and number of channels.
Broadcasting instances are setup differently, you can now specify a subnet. To broadcast to the entire network (as before) specify 255.255.255.255 as the IP.
DBP users must delete packets that use encryption otherwise deadlock will occur upon application exit because the application will wait for a packet to close down the encryption threads.
Other changes to be aware of:
DBP users cannot view documentation in the IDE since the new documentations structure does not allow this.
C++ users must include MikeNet/FullInclude.h instead of MikeNet.h
C++ and .NET users must change operationID, clientID and instanceID data types to size_t or unsigned int.
C++ users, commands are split into 3 namespace: mn, mnNAT, mnSound.
.NET users, the class containing all of the commands has been renamed to mnCLR.
*****VERSION 1.1.7******
- Performance has improved for sending data. Non blocking (asynchronous) now performs just as well as blocking (synchronous).
- Performance has improved for receiving data, especially when dealing with a large number of instances or clients.
- mnAdd commands now increase the memory size so you no longer have to use mnSetMemorySize or mnChangeMemorySize before adding data. Note that changing the memory size regularly will reduce performance significantly.
- Fixed a bug where mnStartFirewall could throw an error on some systems.
- Fixed a bug where mnAddStringC increased the used size too much when adding small strings.
- Fixed a vista compatibility problem with some of the demo projects. This problem meant that connections could not complete.
Note that this problem was fixed by simply changing the demo project code.
*****VERSION 1.1.6******
- Improved receive performance
- mnEncrypt now allocates new memory if not enough is available
- mnDisableDebug no longer disables mnGet or mnDecrypt error messages, it now only disables internal receive related client and server message boxes.
- Significantly improved performance while auto resize TCP is enabled in standard TM_SIZE TCP mode.
- Added mnGetProfileAmount and mnGetProfileType firewall commands.
- Added mnGetAutoResizeTCP.
- Updated UPnP and File Transfer demos to use new commands
Bug fixes:
- mnChangeBufferSizeTCP did not work.
- mnSendTCP and mnSendUDP didn't check client ID parameter in server state, UM_CATCH_ALL (3) and UM_CATCH_ALL_NO (4).
- mnSetSendTimeout now properly disconnects clients after the timeout period expires.
- mnGetTCPRecvSizeA and mnGetTCPRecvSizeB now return correct value.
- mnSetAutoResizeTCP caused unexpected error if client ID was 0 in server state.
- Updated documentation, alot of firewall commands were missing because the program I use to generate the HTML files didn't load the entire document.
*****VERSION 1.1.5******
DarkNet has been optimised and restructured. There isn't much that hasn't improved in efficiency, so hopefully you will notice some kind of performance increase.
The help files have been completely rewritten and are much more useful and easy to use.
There is now alot of new demo code. There are now 19 projects demonstrating various aspects of DarkNet.
There are also several bugs that have been fixed:
- Packet commands may not always display correct error message when there is not enough memory in packet to add or get data.
- Packets may not always have variables such as client ID set properly.
- Server/clients could not continue to transfer data in UDP mode 2 and 1 after 49.7 days of being connected.
- Vulnerability where certain situations could cause the server to display an error message or be unable to receive UDP data.
- mnFinish would not re-enable UDP on the specified instance.
- mnToggleAffinity, mnGetAffinity, mnSetAffinity, mnGetPriority and mnSetPriority were not working.
You can now have more than one error mode enabled at the same time using mnToggleErrorMode. mnGetErrorMode has changed as a result.
Save error mode has improved so that you don't have to check the return values of commands to determine if an error has occurred. Instead you can use mnGetErrorFlag to determine when an error has occurred. You can use mnSetErrorFlag and mnClearErrorFlag to toggle error state and control what mnGetErrorFlag returns.
A clError (C++) and mnError (.NET) exception class now exists. When exception error mode (new) is enabled DarkNet functions will throw an exception of this type when an error occurs. The exception class is used internally to DarkNet; you now have the option to integrate your applications with the same error system that DarkNet uses. The documentation explains how to do this.
mnGetErrorMode now takes an error mode parameter and is used to determine whether an error mode is on or off.
There is demo code showing how to use the new error system.
Several new commands exist which make DarkNet packets more useful and dynamic.
mnErase can be used to erase a portion of the packet whilst mnInsert can be used to insert space into the packet, which can then be filled with an mnAdd command (e.g. mnAddInt).
A new command mnCreatePacketFromPacket exists which is faster than mnCreatePacket + mnEqualPacket. It has the same result as using those two commands.
There are several new string commands which operate similarly to their packet counterpart: mnCreatePacketFromString, mnComparePacketString, mnEqualPacketString.
mnChangeMemorySize can be used to change the memory size of a packet without wiping its contents (mnSetMemorySize wipes the contents of the packet).
mnAddMemblock and mnGetMemblock have been added for DBP users so that memblocks can be used with packets.
Several new networking commands have been added.
mnFlushRecvUDP and mnFlushRecvTCP can be used to empty the packet queue whilst mnGetTCPStoreAmount and mnGetUDPStoreAmount can be used to determine the number of packets in the queue. Note: packet queue refers to the queue of packets waiting to be received via mnRecvUDP or mnRecvTCP.
mnChangeBufferSizeTCP can be used to change the maximum possible size of an incoming TCP packet whilst the instance is active. This operates on a per client basis. mnGetTCPRecvSizeB exists to retrieve buffer sizes on a per client basis.
mnSetAutoResizeTCP can be used to set no limit on the maximum possible size of incoming TCP packet. The buffer size will increase as necessary. This operates on a per client basis.
mnGetTCPBytes is similar to mnGetTCPPercent except it retrieves the number of bytes worth of partial data (data that does not make up a complete packet).
mnDisableTCPHandshake can be used to disable the TCP handshake process. When this process is disabled DarkNet can communicate with applications not written with DarkNet. mnGetTCPHandshakeEnabled exists to check whether TCP handshake has been disabled.
mnSetTCPMode can be used to change the TCP mode to the new postfix mode which adds specified bytes of data to the end of each packet, and checks for these bytes at the end of incoming data to determine when a complete packet has been received. mnGetTCPMode exists to determine the TCP mode.
mnSetTCPPostfix can be used to set the postfix used with the postfix TCP mode. mnGetTCPPostfix exists to determine what the postfix is.
mnSetTCPMode and mnDisableTCPHandshake make communication via HTTP possible. Demo code exists to demonstrate this.
Graceful disconnecting is now possible using mnShutdownClient, mnEnableGracefulDisconnect and mnGetGracefulDisconnectEnabled. This allows clients to disconnect but data transfer to complete successfully.
mnSetSendTimeout and mnGetSendTimeout exist to protect the server from malicious clients. After the send timeout expires, if a packet has not been sent the client is forcefully dropped. This prevents blocking send operations from blocking permanently.
There is a new UDP mode (4) UM_CATCH_ALL_NO, UDP mode catch all, no out of order which is used in exactly the same way as UDP mode catch all but out of order packets are discarded.
All UDP modes now have procedures to ensure that data transfer can continue forever. Previously UDP modes 1 (per client) and 2 (per client, per operation) would stop working if a client did not disconnect after roughly 49.7 days.
mnDisableNagle and mnGetNagleEnabled can be used to disable the Nagle Algorithm which may improve TCP performance for some applications.
mnConnect and mnPollConnect can now return -2 indicating that the server rejected the connection request. This normally means the server is full.
Roughly 90 new firewall commands have been added which allow full control over windows firewall.
Roughly 50 new sound input/output commands have been added which allow sound data to be input, sent and played. This facilitates voice communication.
*****VERSION 1.1.4******
In this version are the following bug fixes:
1. Late connection packets
Fixed bug where UDP modes: 'per client' and 'per client, per operation' could wrongly disconnect clients and generate debug
error messages and UDP mode 'catch all' could wrongly receive connection packets in server state. This occurs on rare occasions
when connection UDP packets arrive late (after the connection process has been completed). This is more likely to happen when
the client/server connection quality is poor.
The issue with UDP mode 'per client' and 'per client, per operation' has been fixed. With UDP mode 'catch all', you must ensure
that your code deals with this rare occurrence. The connection packets always have a prefix of an unsigned integer of 0 and should
be ignored. The documentation has been updated with this information.
2. Rare 'no prefix' problem
On packets where there is no UDP (clock value) or TCP (packet size) prefix, on rare occurrences an undefined prefix could be added
which causes problems when in UDP mode 'catch all' and when connecting to a server. This has been fixed.
3. mnGetLogicalCPU and mnGetPhysicalCPU
These commands were returning wrong values. This has been fixed.
mnGetLogicalCPU will now only return a correct value on Windows Vista, Windows XP Professional x64 Edition, Windows XP with
SP3 or later.
In the event of an error when using either of these commands a value of 1 will be returned.
*****VERSION 1.1.3******
There are some new DarkNet errors which help to prevent basic coding mistakes. e.g. using mnStart multiple times in a row;
using certain commands on an instance that is not active i.e. mnStartServer, mnConnect or mnStartBroadcast have not been used;
starting an instance twice in a row.
Performance has increased slightly. mnSend commands are more efficient and TCP multithreaded receiving performance has improved.
A couple of bugs have been fixed:
-Fixed a rare issue where using mnFinish could cause the application to freeze indefinitely.
-Fixed a UPnP issue where DarkNet had trouble dealing with blank port map settings e.g. a port map's description could be blank.
*****VERSION 1.1.2******
Added UPnP commands which adds support for programmatic port map configuration.
E.g. you can now setup port forwarding programmatically.
Improved performance of mnSend commands.
Error message boxes have been changed slightly and mnGetErrorFile has been added due to
MikeNet being split up into multiple files.
Added mnGetVersion which returns version information of MikeNet.
New error messages have been added, some of which can be disabled using mnDisableDebug
which disables errors that can be caused by rogue clients.
Demo code has been updated to improve readability.
The following bugs have been fixed:
1. Connection packets from the client can no longer be received in UDP mode catch all. Previously packets
with a prefix of 0 (integer) could be received by the server shortly after a client connected in UDP mode catch all.
2. In C++ deallocating a string with delete[] will not cause a crash when the return value of mnGetStringC is an
empty string due to an error occurring.
3. Fixed rare occurrence of heap corruption during mnFinish due to freeing of resources before closesocket
operation completed.
4. Fixed memory leak occurring where mnFinish did not deallocate packet stores (e.g. TCP received packets
that had not yet been received via mnRecvTCP).
5. Changed mnGetPhysicalCPU and mnGetLogicalCPU so that if no CPU cores are detected a value of 1
is returned. This fixes a rare case where mnStart creates no threads when number of threads is set to 0.
6. Fixed the return value of several commands that were returning wrong values. This bug was normally
only apparent in the event of an error.
*****VERSION 1.1.1******
New stable error system. mnClearError removed, mnGetErrorCommand added.
You can now change the priority and affinity of MikeNet worker threads
with mnToggleAffinity, mnSetAffinity, mnSetPriority, mnGetAffinity, mnGetPriority.
You can now add packets together, determine whether two packets are the same and
copy the contents of one packet into another. The new commands for this are
mnAddPacket, mnComparePacket and mnEqualPacket. C++ and .Net users can use the operators
of the clPacket and Packet class.
MikeNet is now compatible with .Net and there is demo code for C# and VB.
Bug fixes:
1. If maximum number of operations was not set to 1 with mnStartServer in "per client"
UDP mode crashes would later occur. You can now set this value to anything in this mode.
2. In "per client, per operation" only an operation ID of 0 would be accepted.
All operation ID should now work properly.
3. In DBP bytes are now returned properly so that they can be passed directly to a function
without having to store them in a byte variable first.
*****VERSION 1.1.0 Build 3******
MikeNet applications now work on versions of windows older than XP.
*****VERSION 1.1.0 Build 2******
DBP users can now use many commands as if they did not have a return value.
*****VERSION 1.1.0 Build 1******
The following commands now have a return value: mnSetFunction, mnFinish, mnDisconnectClient,
mnSetServerTimeout, mnDisableUDP, mnStopConnect.
mnGetUDPEnabled now returns integer instead of bool.
mnGetLocalIP now takes a parameter of unsigned integer instead of signed to bring it in line
with mnGetLocalIPAmount's return value.
MikeNet is more secure meaning that it is now harder to crash MikeNet due to wrongly using
a command (e.g. using an instance without creating one with mnStart).
Encryption/Decryption commands have been added that use the Advanced Encryption Standard.
The new commands are: mnCreateKey256, mnCreateKey192, mnCreateKey128, mnDeleteKey, mnEncrypt,
mnDecrypt, mnSetDecryptUDP.
Possible error messages that could occur from using each MikeNet command are now documented.
*****VERSION 1.0.9******
The packet formulation/deformulation system has been rewritten to give far greater flexibility.
Broadcasting capability has been added which enables messages to be sent from one device to all
other devices on a LAN without having to setup a connection.
Added mnEnableMessageBoxes to re-enable error message boxes after disabling them.
Catch all UDP mode has been added. In this mode no packets are discarded, allowing you to decide
which ones to drop after using mnRecvUDP.
Added ability to list available local IP addresses.
Added advanced feature for C++ users: Optionally, instead of using the mnRecv commands you can
set an application defined function to be executed every time a packet is received.
Added HTML help files for DBP users.
Added New advanced MikeNet demo (known as cube world pro)
Fixed the following bugs:
1. mnGetLocalIP returned 0.0.0.0 when MikeNet allocates the IP automatically in server state.
2. mnFinish could sometimes cause an access violation.
3. mnPollConnect and mnStopConnect would not work for DBP users.
mnGetUnsignedShortInteger and mnAddUnsignedShortInteger have been renamed as: mnGetUnsignedShortInt
and mnAddUnsignedShortInt so that they are similar to other commands.
mnGetError commands now return C string instead of standard string. This only affects C++ users.
*****VERSION 1.0.8******
Fixed several bugs concerned with mnConnect, mnStart and mnFinish.
*****VERSION 1.0.7******
Added instance system allowing multiple connections/server hostings.
Added mnPollConnect and mnStopConnect and changed mnConnect. This increase functionality of the
connection process.
Added DNS compatibility so that IP addresses can be retrieved from domain names.
Added ability to disable UDP.
Added ability to change server connection timeout value.
Changed parameters of mnAddString and mnGetString.
Fixed a bug causing disconnection or errors due to incorrect buffer sizes.
*****VERSION 1.0.6******
Clients can now receive using a client id of 0. This enables the server to send UDP data to a client
when this UDP data is not related to another client.
*****VERSION 1.0.5******
Fixed another bug that could cause the server to become unresponsive. All of these sort of bugs
should now be resolved.
Improved performance of send commands.
Fixed a bug that meant that if a send operation fails, memory is not properly deallocated
(present in all past versions).
Fixed a bug that meant that send operations from the server would not work (new to v1.0.4).
Changed mnGetClientId to mnGetClientID. DBP users do not need to worry about this because DBP is
not case sensitive.
Changed the DBP ini file so that the parameters of the mnSendAll commands are correct.
*****VERSION 1.0.4******
Fixed a bug with the new connection system that meant that in certain circumstances clients were
unable to connect.
Fixed a bug that meant in certain circumstances the server would become unresponsive.
*****VERSION 1.0.3******
mnConnect and mnStartServer's parameters have changed to make them more user friendly.
To change the buffer sizes you should now use mnSetBufferSizes.
To manually set local address information you should now use mnSetLocal.
TCP store size on the server side has been removed.
Send buffer size on both the server and client side has been added. This is the maximum size that
a send packet can be including its prefix (an integer, normally 4 bytes).
TCP receive size must now be equal to or greater than the size of any incoming TCP packet
(including its prefix); previously it could be smaller so long as the TCP store size was large enough.
To disable message boxes from appearing whenever an unexpected error occurs you should now use
mnDisableMessageBoxes.
Client's can now connect to servers when behind a router with NAT enabled. Previously the
client would experience problems.
In client state, you can now find out what your client id is using mnGetClientId.
All commands that had UDP or TCP in their name now have this in upper case e.g. mnGetTcpPercent is
now mnGetTCPPercent. DBP users do not need to worry about this because DBP is not case sensitive.
UDP and TCP are now treated separately e.g. Your TCP and UDP local port/IP can now be different.
mnTCPPacketsWaiting has been removed
mnRecvTCP returns a number greater than 0 if a new packet has been received. This number indicates
the number of TCP packets in waiting.
Commands concerned with buffer sizes now return or take unsigned integer instead of signed integer.
TCP performance has greatly improved
Packet formulation performance has improved
mnRecvUDP will not receive packets that have already been received. Previously mnRecvUDP would
always receive a packet and if no new packets were present it would use the last packet received.
*****VERSION 1.0.2******
Version 1.0.2: Changed the send all commands so that you have the option of sending to all but one.
*****VERSION 1.0.1******
Version 1.0.1: Fixed bug that meant if performing mnGetString() on a string that is not at the start
of the packet, an empty string would be returned.
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.