|
Product Menu
Community
Join thousands of game developers in our forums and read over 1.9 million messages
Top 10 This Week Latest Releases Upgrades
Toolbar
|
![]() DarkNet
DarkNet is a multiplayer plugin specifically designed for use in game development. It uses both UDP and TCP protocol making it suitable for virtually any type of online game ranging from fast paced first person shooters to large scale massively multiplayer online games. It is very easy to use and well documented with several code examples. DarkNet is compatible with Dark Basic Professional, C++ and .NET compatible languages (e.g. C#, VB.NET). High performance
Throughout development there has been a great deal of focus on maintaining high performance.:
Special Offers
Order Online
Ease of use
DarkNet is very easy to use and is useful to programmers of all ability. Basic easy to use commands exist for beginners, whilst more advanced users can make use of additional commands intended to maximize performance (e.g. mnSetFunction). Take a look at a basic example application created in Dark Basic Professional that sets up a server and accepts new connections. Without DarkNet this would take hundreds of lines worth of complex code to create a basic server:
` Start DarkNet
mn Start 1,0
` Start server
mn Start Server 0,50,5,1
` Display information about server
print "Local TCP IP: " + mn Get Local IP TCP(0)
print "Local UDP IP: " + mn Get Local IP UDP(0)
print "Local TCP Port: " + str$(mn Get Local Port TCP(0))
print "Local UDP Port: " + str$(mn Get Local Port UDP(0))
print
do
` Check for new clients
iJoined = mn Client Joined(0)
if iJoined > 0
print "A new client joined the server"
endif
` Check for leaving clients
iLeft = mn Client Left(0)
if iLeft > 0
print "A client left the server"
endif
loop
Asynchronous
All DarkNet commands have a non blocking option so that your application can continue operating whilst a DarkNet operation completes. This is most useful when connecting to a server. Whilst connecting a handshaking process completes behind the scenes and this can take several seconds on slow connections. There are two ways of using mnConnect in DarkNet. Note that all other commands that may take several seconds to complete operate in a similar way.
Error System
DarkNet includes a versatile error system which can be used in a variety of ways. There are 3 error modes available; you can use more than one at the same time. mnToggleErrorMode is used to enable or disable an error mode. All error modes provide useful information about the error. The following information is provided:
Documentation
Every command in DarkNet is documented fully, as well as this certain concepts such as UDP modes and instances are explained. All documentation is in HTML format. You can view the documentation online or you can download the documentation in a zip file. The root of the documentation is DarkNet Help.html. Stability
DarkNet is extremely secure and designed with an intuitive error reporting system. By default error message boxes are enabled which means that whenever an error occurs, an error message is displayed which explains the error in full. Optionally you can disable error message boxes and use mnGetError commands which allow you to get information about the error and deal with it yourself. Packet Encryption / Decryption
Encryption and Decryption of packets is supported which means that sensitive data can be transferred between applications without fear of malicious interception. Advanced Encryption Standard is used to encrypt the packet on the sending end and decrypt the packet on the receiving end. The example code below (for Dark Basic Professional) shows how easy it is to encrypt and decrypt packets in DarkNet. The packet is encrypted and decrypted and its contents are displayed at each stage: ` Create packet Packet = mn Create Packet() mn Set Memory Size Packet, 1024 ` Create key to be used when encrypting ` The 4 parameters of mnCreateKey256 act as a password ` Without these values it is impossible to decrypt the packet Key = mn Create Key 256(1251521,15215215,121512515,151252151) ` Get input InputData$ as string Input "Enter data to be encrypted: ",InputData$ print print ` Load input into packet mn Add String Packet,InputData$,0,0 ` Display packet contents DisplayContents(Packet,"Original contents: ") ` Encrypt the packet using the key that we created earlier mn Encrypt Packet,Key ` Display encrypted contents DisplayContents(Packet,"Encrypted contents: ") ` Decrypt packet using the key that we created earlier mn Decrypt Packet,Key ` Display decrypted contents DisplayContents(Packet,"Decrypted contents: ") print "Press any key to exit..." wait key end ` Outputs the contents of Packet with TextData$ prefix function DisplayContents(Packet as double integer, TextData$ as string) ` Move cursor to start of packet mn Set Cursor Packet, 0 ` Return string containing contents of packet Contents$ = mn Get String(Packet, mn Get Used Size(Packet), 1) ` Write packet contents to screen print TextData$ print Contents$ print endfunction Multiple Instances
DarkNet's instance system allows you to create and control multiple connections. This means that a single application can host and connect to multiple servers at the same time. This dramatically increases the options available to you. Here are some options that this feature opens up to you:
Broadcasting
DarkNet's broadcasting feature allows applications to transmit data to all devices on a LAN without directly connecting to the devices. An example use for this is clients generating a list of available local servers. The server broadcasts its availability including its IP and port to all devices on the network. Using the client application, devices can listen for the broadcast and use the information in the broadcast packet to connect to the server. DNS
DarkNet is able to retrieve IP addresses from domain names. This is especially useful for servers that are hosted on dynamic IP addresses that change from time to time. NAT Compatibility
Clients who are behind a NAT (Network Address Translation) enabled router can connect to remote servers and communicate normally using both UDP and TCP protocol. Non blocking option
DarkNet provides non-blocking (asynchronous) options for commands that would otherwise block for a noticeable length of time. By performing operations in a non blocking manor other things can be done whilst an operation completes. UPnP
DarkNet includes UPnP (Universal Plug and Play) functionality which allows applications to programmatically create, edit and delete port forwarding entries on a router. This is useful for server hosting and peer to peer applications. Demos
Included with DarkNet are 16 demo projects containing code in C++, VB.NET, C# and DarkBASIC Pro. Sound Input
DarkNet includes a set of commands for gathering sound input from input devices e.g. microphone. Multiple input device can be used at the same time. Input is un-paused using mnUnpauseInput and paused using mnPauseInput. While input is un-paused a stream of data will be received in the form of packets. This data is retrieved using mnGetInputData. The sound format can be adjusted which changes the quality and size of data received. The format can be set to 3 preset quality levels using mnSetInputFormatLow, mnSetInputFormatMedium or mnSetInputFormatHigh. Alternatively precise format values can be specified using mnSetInputFormat; the following values can be set: Channels, Samples per second (hertz) and Bits per sample. Sound Output
DarkNet includes a set of commands for sending data to sound output devices such as speakers. Multiple output devices can be used at the same time. mnPlayData is used to send a packet containing data to be played. Such packets can be retrieved from an input device using DarkNet or can be created by other means e.g. from a file. The sound format can be adjusted which changes the quality of output. The format can be set to 3 preset quality levels using mnSetOutputFormatLow, mnSetOutputFormatMedium or mnSetOutputFormatHigh. Alternatively precise format values can be specified using mnSetOutputFormat; the following values can be set: Channels, Samples per second (hertz) and Bits per sample. Windows Firewall
Using DarkNet you can control all aspects of windows firewall which is included with microsoft windows SP2 and later. Approximately 100 firewall commands exist which are easy to use and powerful allowing you to retrieve and change all windows firewall settings. mnSetFirewallEnabled can be used to enable or disable windows firewall. mnAddApplication can be used to add a firewall exception and allow an application to bypass the firewall. Further Information
To view more detailed information about DarkNet please visit the DarkNet developer website. |