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: 12th May 2010 04:17
You can do this:


to get the IP of the server but after that you need to communicate directly with the server to retrieve what file you want.

A word of warning, avoid using HTTP extensively as there is a limitation that I didn't think about while writing the second TCP mode. Sometimes the HTTP postfix that DarkNet looks for isn't appended by the HTTP standard. This means that data is sometimes never passed to mnRecvTCP when communicating with a web server.

I have already come up with a quick solution to this problem so if you really need to use HTTP email me and tell me what language you are using and I'll send you the update. The next version will include some more useful commands to solve this problem but the hotfix is sufficient for now.

I'm very excited about releasing the code, it is very pretty. To clarify, I will finish the next version during the Summer around August, September time.

GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 26th May 2010 05:28
Michael:

I remember you saying awhile back that you were working on file downloading as part of DarkNet. This still true? I am looking for a way to download patches in-game. A non-blocking file downloader with the partner mnPollDownload, mnDownloadProgress, and mnStopDownload would be awesome.

Thanks for everything so far.

Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 26th May 2010 09:13
Quote: "I remember you saying awhile back that you were working on file downloading as part of DarkNet. This still true? I am looking for a way to download patches in-game. A non-blocking file downloader with the partner mnPollDownload, mnDownloadProgress, and mnStopDownload would be awesome."


I believe he added those commands in the hot fix he gave me, so they should be in the next update .

KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 26th May 2010 19:15
I just made my own downloader with the packet commands available. It seems to be pretty quick, and works quite well.

What would be the advantages of specific file downloading commands?

Background downloading perhaps? But I would want to know how it works.

GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 27th May 2010 01:29
Quote: "Background downloading perhaps?"


That is exactly what I want. A progress bar on the screen that I update every loop to the exact % of the file being downloaded, meanwhile the user can scroll through the "Patch Notes" while waiting. For all that to occur, the actual download itself has to be nonblocking, or happen in the background.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 27th May 2010 02:05
Details of the hotfix (which you can get by emailing me):
There are two new commands:
- mnSetTransferEverythingTCP: when enabled the postfix TCP mode will be overridden and any data received will be instantly transfered to mnRecvTCP without looking for any postfix. You can only use this during run time (not before an instance has been initiated) and can use it as many times as you like to enable/disable 'transfer everything' mode.

-mnGetTransferEverythingTCP returns the status of the 'transfer everything' mode (true if it is enabled, false if not).

So, just before you detect that a file is going to be received use mnSetTransferEverythingTCP to enable 'transfer everything', then after the file has been received disable it again. If you are using keep-alive (HTTP option) you will need to re-disable 'transfer everything' after the file has been received, which you can determine by waiting for the size in bytes of the file to be received.

This is necessary only for HTTP communication as the postfix expected by DarkNet is not always present.

These two new commands will probably not be in the next official release as its not a very flexible way of dealing with the problem. Instead a much better system will be in place.

Background downloading can be achieved with the current version. Send the files as one single TCP packet and use mnGetTCPBytes or mnGetTCPPercent to determine how much of the packet has been downloaded.

GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 27th May 2010 02:11
Quote: "Background downloading can be achieved with the current version. Send the files as one single TCP packet and use mnGetTCPBytes or mnGetTCPPercent to determine how much of the packet has been downloaded."


That works if you are connecting to a server running DarkNet. Can you do the same to just download a file, say from an FTP server?

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 27th May 2010 02:16
I assume that's using the postfix TCP mode. mnGetTCPPercent won't work but mnGetTCPBytes will, so if you know the size of the file you are receiving you can do mnGetTCPBytes divided by the size * 100 and you get the percentage (which is all that mnGetTCPPercent does).

Background downloading is more difficult though because you would probably have to use mnSetTransferEverything. But you can run the code for dealing with each fragment at the same time as doing other things.

KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 27th May 2010 18:45
Quote: "That is exactly what I want. A progress bar on the screen that I update every loop to the exact % of the file being downloaded, meanwhile the user can scroll through the "Patch Notes" while waiting. For all that to occur, the actual download itself has to be nonblocking, or happen in the background."


That's exactly what I wrote using the current DarkNet commands.

It uses BlueGUI to show a progress bar for each file being downloaded, and shows a browser window that displays the patch notes from my website.

Join at www.worldsapartonline.net and I'll put you in the Alpha test group so you can download the installer and see it in action.

GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 15th Jun 2010 07:50 Edited at: 15th Jun 2010 08:15
Quote: "mnSetTransferEverything"


Did you update and not tell me? I don't have this command...

Edit: Ha ha, silly me. I see your post just a few above this one. Will email you in the morning when I start thinking clearly again.

I looked into what KISTech did with his autoupdater. It is good, but I don't want my game EXE handling the transfer of files, it is busy enough as it is. I am going to use a web server for the files. I looked at your "HTTP Client" demo and reworked it for what I want. I made a library for myself and it looks awesome! Here is example code of how I download a whole bunch of files at once:



The library handles connecting, setting graceful disconnect, and everything else that your "HTTP Client" demo does.

I did run in to one problem though. My web server seldom sends the last packet of any file. Or maybe it does, but I don't receive it. I tested with a whole slew of files and it is hit and miss. It appears to split the file up by lines (chr(13)+chr(10) as the divider), and I seldom receive the last split of the file.

Any suggestions? Perhaps your new mysterious command is what I seek!

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 15th Jun 2010 14:56
@ GIDustin
The problem you describe is what the hotfix works around. You only receive parts of the file when the bytes of that file coincidentally form the divider (chr(13)+chr(10)). The hotfix allows you to override DarkNet's data management system so that any data received is passed straight to you regardless of the divider.

@ All
I just upgraded from VS 2008 Pro to VS 2010 Pro with Visual Assist X. This will dramatically increase my productivity, similar to going from notepad to NetBeans for java developers !

KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 15th Jun 2010 18:20
@GIDustin,

The downloader is actually a separate program, and doesn't involve the game client at all. In fact I'll probably end up making it more generic so it can be used for other projects too. It's more of a frontend program, similar to what games like Battlefield Bad Company 2 are doing.

The one down side I can see with doing your file downloading from a web server is speed. The web server has to go and pull each file from the hard drive, and it doesn't typically do it all at once unless it's a small file, so there will be pauses as it reads in the next chunk it's going to send.

SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 17th Jul 2010 19:46 Edited at: 17th Jul 2010 20:11
For anyone interested in implementing voice chat into their game, below is a simple program to illustrate how to incorporate it using DarkNet's input system with DBPro's memblock and sound systems. It's also posted in the codebase.



KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 17th Jul 2010 19:51
Nicely done. This will certainly come in handy.

Malibu
14
Years of Service
User Offline
Joined: 13th Mar 2010
Location:
Posted: 1st Aug 2010 16:29
Hi all

is there a way to connect through a proxy to an game server?
Interplanetary Funk
14
Years of Service
User Offline
Joined: 19th Apr 2010
Location: Ipswich, United Kingdom
Posted: 7th Aug 2010 19:10
I've downloaded DarkNet (DBP) and am so far finding it really good, except that the server's not sending packets.I made a post in the DBP forum so I'll link you to that instead of spamming this thread:
http://forum.thegamecreators.com/?m=forum_view&t=173786&b=1

Also, is the hot fix I read about above available for DBP or just C++? As I would love to have the file transfer commands.
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 19th Aug 2010 00:03
@ Malibu
Yes I don't see why not? The proxy should forward everything automatically.

@ Planetary Funk
Problem solved in that thread. The hotfix is available to all languages, just email me and I'll reply with it.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 23rd Aug 2010 22:50
Hi all,

It has been a while since I've given you an update on the next version.

I've been rewriting it more or less from scratch and have been documenting the networking module which has been very time consuming. Today I finished documenting the module and have uploaded it so you can have a look at it. The index page can be found here:
http://www.darknetworking.net/GeneratedDocumentation/html/index.html

You can see the documentation for commands from v1.0 here:
http://www.darknetworking.net/GeneratedDocumentation/html/namespacemn.html

I recommend using the search feature at the top right as there are a lot of commands. There are some differences between the commands in the current version and the commands in v2.0 but they are all very similar.

Tomorrow I will begin testing the networking module, which will give an indication of when I will be able to release this.

I am currently still in the rewriting phase and haven't added any new features.

I will update this documentation as I progress to the other modules, I'll keep you posted!

GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 24th Aug 2010 05:42 Edited at: 24th Aug 2010 05:47
Oh boy, that new documentation has alot of unfamilar stuff in it. I see that most commands are listed twice. I am hoping that most of the changes apply to the C++ version and that DBP will remain mostly the same.

Any chance you could post a demo "cube world" using the new commands so we can start to get familiar with any new processes?

Look forward to seeing the finished product.

Edit: I didnt see any mention of encryption on the site, are those commands gone?

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 24th Aug 2010 12:08 Edited at: 24th Aug 2010 17:23
Quote: "Oh boy, that new documentation has alot of unfamilar stuff in it. I see that most commands are listed twice. I am hoping that most of the changes apply to the C++ version and that DBP will remain mostly the same."

Most of the unfamiliar stuff is C++ only.

All of the classes are for C++ users, they can build upon the DarkNet structure and create custom instances and modes. This documentation is not just a documentation of what is designed specifically for users of DarkNet, its is documentation of the actual DarkNet code aswell.

Main changes so far:
- GetClock which returns a value stored in received packets in UDP mode 'per client, per operation', 'per client' and 'catch all, no out of order' has been renamed GetAge.
- Instance profiles have been introduced. Instead of changing the settings of one instance at a time (e.g. mnSetLocal), you now change the settings of an instance profile which stores these settings. When you setup an instance (e.g. mnConnect) you pass it an instance profile.
- Data types have changed. Client ID and operation ID are now size_t. size_t and INT_PTR are a 32bit unsigned integer (or DBP DWORD) on the 32 bit version and a 64bit unsigned integer on the 64 bit version. size_t replaces all occurrences of unsigned integer. INT_PTR replaces all occurrences of long long integer referring to a memory address.
- Every command where a parameter or return value is a DarkNet object now has an additional C++ version where instead of passing an INT_PTR, a reference or pointer to the actual object is passed.

I think that the changes above are fairly minor, and this is probably as much change to existing commands as there will be in the final release for the networking module.

Quote: "Edit: I didnt see any mention of encryption on the site, are those commands gone?"

They are not gone, I just haven't rewritten them yet. Same goes for sound, UPnP and firewall commands.

Quote: "Any chance you could post a demo "cube world" using the new commands so we can start to get familiar with any new processes?"

Yep I will be doing this soon, will post here when done.


[edit] Just fixed a mistake in the documentation where full stops appeared in strange places.

GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 30th Aug 2010 08:06
Quick question about packet encryption.

mn Create Key 256() takes 4 "long long" as parameters. I am not entirely familiar with C++, but what is the range on a long long? Is it the same as a dword?

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 30th Aug 2010 11:18
–9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. This is the same range that DBP's DOUBLE INTEGER has.

KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 30th Aug 2010 20:10
I had a quick question about the encryption too.

If making it public knowledge would put it more at risk of being cracked then don't answer, but what type of encryption is it?

..and the big question, how difficult do you think it is to crack?

GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 30th Aug 2010 21:12 Edited at: 31st Aug 2010 04:52
While You are at it...
Is there a way to pass a string as the key or do I need to make my own function to turn a string into a series of double ints?
Edit: This will be difficult as you cannot use bitwise operations on double ints.... Can we get a mn encrypt key 256(dword1, ... , dword8) instead? Or a string equivalent?

Also, is there a way to tell if the packet is encrypted?

Edit: I am trying to recreate the login routine found at this link, which uses a different encrypt key for each client. This means that if I want to send a packet to every client, I need to encrypt it for that client. So I am assuming I will need to "encrypt packet, send to client, decrypt packet, repeat". It would be neat if an encryption key could be tied to a client and have it all handled automatically.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 31st Aug 2010 12:11 Edited at: 31st Aug 2010 12:13
Quote: "I had a quick question about the encryption too.

If making it public knowledge would put it more at risk of being cracked then don't answer, but what type of encryption is it?

..and the big question, how difficult do you think it is to crack?"

It uses Advanced Encryption Standard, based on its specification.

It is currently impossible to retrieve the original data without using the exact key that was used to encrypt the data.

The key being used by a DarkNet application can be retrieved though since the key must be stored in memory and is until 'mn delete key' is used. I'll be looking at making this a little more secure, but any good hacker should be able to retrieve something useful from memory.

Quote: "While You are at it...
Is there a way to pass a string as the key or do I need to make my own function to turn a string into a series of double ints?"

Yes, you can do this using packets. Everything in a packet is stored in bytes, each letter of a string is a byte. So if you use mnGetByte after adding a string you can retrieve the value of each character. Similarly, a DWORD is 2 bytes and a DOUBLE INTEGER is 4 bytes. So you can add a string and then retrieve any data type from it. The retrieved result will always be the same and change depending on the contents and size of the string.

Here is a code sample:


Quote: "Edit: I am trying to recreate the login routine found at this link, which uses a different encrypt key for each client. This means that if I want to send a packet to every client, I need to encrypt it for that client. So I am assuming I will need to "encrypt packet, send to client, decrypt packet, repeat". It would be neat if an encryption key could be tied to a client and have it all handled automatically."

I may look at implementing that, will be working on the encryption module soon.

Quote: "Also, is there a way to tell if the packet is encrypted?"

No but you can code this yourself. See this example:


Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 16th Sep 2010 22:27 Edited at: 19th Sep 2010 22:22
Here is an update on how close the new version is to being finished.

I completely finished and tested the rewritten networking module yesterday and it is so so sweet. I am nearly done with UPnP too and will finish that tomorrow morning.

Left on my to do list:
- Encryption.
- Sound input/output.
- New networking features.
- Firewall.

Networking was by far the biggest job to rewrite, taking months of design and coding. The others are comparatively small.

I am working flat out on week days to get this ready and will definitely be releasing something by next Friday.

This version means that the internals of DarkNet are much better, such that the following have improved massively:
- Readability
- Maintainability
- Stability
- Testability

I should also point out that now all important classes have a test method which runs through their methods in a variety of situations to check that the correct output occurs. As well as this I'm now using a good memory leak detection tool. Because of this, this version should be free of any nasty bugs.

All this means that future updates to DarkNet will be much easier and the product as a whole will be much more reliable and flexible.

[edit]
Finished multithreaded encryption and decryption today. It is very cool! It is very efficient at distributing the load so speed is almost exactly multiplied by the number of physical cores you have.

An accidental feature of this system is that if you start encrypting and decrypting the same packet at the same time but one core is slower than the other, one core can finish encrypting and decrypting its section before the other core has even started decrypting!

As well as this you have the option not to block on the Encrypt or Decrypt command, and can poll on its progress while performing other actions, which is nice when encrypting or decrypting large packets.

The way in which I've done this means that all the multithreading is happening under the hood and you don't have to worry about it. You can Encrypt and Decrypt using the new version without changing your application very much; the only difference now is that you have to specify whether to block or not with an additional parameter in Encrypt and Decrypt.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 26th Sep 2010 00:43 Edited at: 26th Sep 2010 01:37
v2.0!
I have at last finished version 2.0 of DarkNet. DarkNet has been rewritten from scratch, which was necessary because it evolved quickly with no clear idea of what the end result would be, leading to code that was difficult to maintain.

The key features new to this version are:
- 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 (which should be substantial).
- 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.

A few things to note:
- The firewall module has been scrapped, as it was becoming redundant as Microsoft looks set to reduce the ability of applications to manipulate the firewall (which is probably a good idea security wise!). I plan to re-include some basic firewall functionality such as sockets automatically adding themselves to the 'allow' list.
- There is less demo code, I will add to this over time but writing demo code for 4 languages is time consuming.

Code does require some (minor) modifications to work with this new version. Here are a list of required 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.
- 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.
- 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.

You may notice not many new features here. Unfortunately I ran out of time . The next thing I will be looking at is HTTP which I will be going into some depth on, to create a high level interface for you.

This update should be released by TGC soon, and will be a free upgrade to existing users. There is likely to be a price rise but I must first negotiate this with TGC. I will be sending out update emails soon for those who bought directly from me.

I recommend you upgrade as soon as possible, because the quality of code is a stretch above the last version. Any problems you experienced with the last version are likely to be fixed and I don't expect any serious bugs in this version because it has been thoroughly tested.

I am very very very very happy with this release, more so than any other release. The code is beautiful and works like a dream, and I hope you share my enthusiasm for it when you take a peak! I'm now going to have a rest, and celebrate. Thank you everyone for all your support, this would not have happened without you. Please post criticisms and thoughts .

KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 26th Sep 2010 04:42
Outstanding. Just in time for the rewrite of Worlds Apart Online in DGDK.

KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 30th Sep 2010 20:57
Any word on when they're going to post the update?

I just checked so I could get started on the networking bit, but it's not up yet...

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 30th Sep 2010 22:15 Edited at: 1st Oct 2010 14:54
Sorry, should be updated tomorrow (in time for the newsletter). We were just finishing off the installer and getting the newsletter ready! New website just finished by the way: http://www.darknetworking.net/GeneratedDocumentation/html/index.html.

[edit] It is out.

Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 2nd Oct 2010 06:08
Why is it so much cheaper on your personal site than on the TGC site? Are they the same product?


Senior Web Developer - Nokia
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 2nd Oct 2010 15:43 Edited at: 2nd Oct 2010 15:43
So far I have received very positive feedback from the new version, all is looking good!

@ Jeku
They should both be 39.99, you might have a link to the old site? If so where did you get it? Or you might have the old site in your cache.

But www.darknetworking.net and www.darknetworking.com are both going to the right place.

And it doesn't matter who you buy from, its the same thing .

Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 2nd Oct 2010 22:30
@Michael P - http://www.thegamecreators.com/?m=view_product&id=2070

It's listed on the TGC site as $61.99


Senior Web Developer - Nokia
Gencheff
14
Years of Service
User Offline
Joined: 12th Jun 2010
Location: UK by way of USSR
Posted: 3rd Oct 2010 00:07 Edited at: 3rd Oct 2010 00:08
Jeku,I think you need to pay more attention my friend

Quote: "MikeNet costs 39.99 GBP..."

From the website.

Quote: "
Price: £ Sterling - £39.99
"


This is from TGC Page.

Or am I mistaking?

Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 3rd Oct 2010 00:40
Oops, you're right

My bad.

Quote: "They should both be 39.99"


Usually I assume $ if no symbol is given explicitly


Senior Web Developer - Nokia
TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 3rd Oct 2010 15:36 Edited at: 3rd Oct 2010 16:04
Quote: "The next thing I will be looking at is HTTP which I will be going into some depth on, to create a high level interface for you."
Hi Mike, congrats on MikeNet 2.0! I like the new look on DarkNetworking.net as well.

I'm curious if 2.0 suffers from the ASCII via HTTP issues (cutting off the last packet) that 1.7 did? If so, I have a found a workaround for some situations, especially if a developer is communicating with a HTTP Server in which they can manage ASCII Files. The ASCII File Workaround - is to place an additional Carriage Return at the very end of the file. This will allow MikeNet to discard the last packet without harm.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 4th Oct 2010 02:20 Edited at: 4th Oct 2010 02:26
Thanks TechLord. Remember though that if a carriage return appears anywhere in the stream of data before the end, then multiple packets will be extracted without that carriage return. If you take that into account then this is a solid work around.

Not to worry though, I have started work on a solution which will make using HTTP much more straightforward.


[edit]
I have received emails about the domain name 'localhost' not working in windows vista and windows 7. I am fairly sure this is a bug in windows, for some reason they messed up the hosts file.

To fix just add the line:
127.0.0.1 localhost

to the hosts file (which opens fine in notepad) and then restart. Mine is at this location: C:\Windows\system32\drivers\etc\host.

TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 15th Oct 2010 23:09 Edited at: 16th Oct 2010 00:11
Mike the HTTP `Carriage Return` POST FIX issue strikes again This time its affecting the download of PNG files. I treat PNG files as Binary Files and use mnSetTransferEverythingTCP Method. In this scenario, our problem is reversed because CR-LF is part of the PNG file signature and somehow DarkNet is missing the CR-LF even with using mnSetTransferEverythingTCP. Without the signature the image is not recognizable.

Quote: "12.11. PNG file signature

The first eight bytes of a PNG file always contain the following values:

(decimal) 137 80 78 71 13 10 26 10
(hexadecimal) 89 50 4e 47 0d 0a 1a 0a
(ASCII C notation) \211 P N G \r \n \032 \n

This signature both identifies the file as a PNG file and provides for immediate detection of common file-transfer problems. The first two bytes distinguish PNG files on systems that expect the first two bytes to identify the file type uniquely. The first byte is chosen as a non-ASCII value to reduce the probability that a text file may be misrecognized as a PNG file; also, it catches bad file transfers that clear bit 7. Bytes two through four name the format. The CR-LF sequence catches bad file transfers that alter newline sequences. The control-Z character stops file display under MS-DOS. The final line feed checks for the inverse of the CR-LF translation problem.

A decoder may further verify that the next eight bytes contain an IHDR chunk header with the correct chunk length; this will catch bad transfers that drop or alter null (zero) bytes.

Note that there is no version number in the signature, nor indeed anywhere in the file. This is intentional: the chunk mechanism provides a better, more flexible way to handle format extensions, as explained in Chunk naming conventions (Section 12.13). "


Ref: http://www.libpng.org/pub/png/spec/1.1/png-1.1-pdg-h20.html#R.PNG-file-signature

If you're curious here is what the HxD Hex Editor is telling me.

PNG File on server (Good)

PNG File downloaded from server (Bad)


We're appear to be missing two bytes: 89 50 4E 47 0D 0A, which just so happens to be CR LF. I confirmed this is the problem by using HxD to insert the two missing bytes in the bad PNG file and it works with no other problems. I believe I can fix this in my code and currently seeking the solution.

Quote: "
Not to worry though, I have started work on a solution which will make using HTTP much more straightforward."
Does this mean DOSP will get a patch for version 1.7 or the new 2.0 version? Either way its Great News!!!

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 16th Oct 2010 01:25
mnSetTransferEverything isn't in 2.0 so if you want to use HTTP stick with the current version. I will email you when HTTP is properly integrated, so your project will receive the next update.

It will be very easy to use such that you won't have to worry about the HTTP protocol very much.

When using transfer everything mode you need to keep it enabled all the time so that all data is properly dealt with, then combine all packets together and parse it correctly.

Unfortunately I am going to be very short on time until the christmas period so you may have to wait a while. You could though, if you wanted, write your own TCP mode to solve the problem (which is what I will be doing anyway), you can then plug this into the rest of DarkNet and use it more or less as normal, but using the internal classes. DarkNet is now open source and well documented so this isn't as hard as it may sound; if you want to do this let me know and i'll email you 2.0.

TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 16th Oct 2010 11:22 Edited at: 16th Oct 2010 11:27
Quote: "DarkNet is now open source and well documented so this isn't as hard as it may sound; if you want to do this let me know and i'll email you 2.0."
Yes, I'm very interested!!!

Kretaner
14
Years of Service
User Offline
Joined: 19th Oct 2010
Location: Crete, Greece
Posted: 19th Oct 2010 12:56
Hey !
Sorry, I knew there must be a information anywhere here ( but i could not find it in this thread):
'When exception error mode (new) is enabled DarkNet functions will ...... see previous definition of 'AF_IPX' 1>C:\Program Files\Microsoft ...'

Problem: I have just updated from DarkNet (MikeNet) 1 (where I had no troubles) to 2 and changed the code.
Now with version 2, when I compile I have the warning:

1>C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ws2def.h(91) : warning C4005: 'AF_IPX': Makro-Neudefinition
1> C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\winsock.h(460): Siehe vorherige Definition von 'AF_IPX'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ws2def.h(131) : warning C4005: 'AF_MAX': Makro-Neudefinition
1> C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\winsock.h(479): Siehe vorherige Definition von 'AF_MAX'

and so on (more than 104 errors and 24 warnings).

I tried the Windows SDKs v.6, v.7.0 and v.7.1 - all with the same result !

What to hell I'm doing wrong ore what has changed from MikeNet 1 to 2, that this happens ?

Thanks for a short hint !
Norman
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 24th Oct 2010 01:58
This probably has to do with the order of includes.

I can't remember what the order should be but swap around:
#include <FullInclude/MikeNet.h>

with any of the following:
#include <windows.h>
#include <DarkGDK.h>

This is not my fault by the way, this is a bug in the winsock2.h header file, making it Microsoft's fault.

TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 25th Oct 2010 12:49 Edited at: 25th Oct 2010 15:55
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 25th Oct 2010 19:34 Edited at: 25th Oct 2010 19:35
I got your original post via mail back:
Quote: "Are InstanceID's reusable? I get the error above when attempting to reuse a InstanceID. Basically, I connect to a HTTP Server pull the file, shutdown the client afterward, reusing the Instance ID. It worked in 1.7."


So I assume you solved the problem? Ran a simple test in DBP and all was fine:


Glad you like the new version , alot of blood, sweat and tears went into it.

There are two known bugs at the moment which I will fix over Christmas (they are not major):
- mnClientLeft can return a client that disconnected but was only partially connected and so not returned by mnClientJoined.
- Changing the TCP mode to TCP_POSTFIX does not disable UDP or handshaking, and should do since UDP is dependent on the handshake process and that process does not always work in TCP_POSTFIX mode.

TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 25th Oct 2010 22:54 Edited at: 25th Oct 2010 22:58
Sorry, Michael. I hoped to pull that post down before I wasted your time. I was using the mn:: DeleteInstanceProfile() and it wasn't enough. What I ended up doing was using the mn: DisconnectClient() method after the shutdown was complete (I did not use this command in v1.7). It now works beautifully. Off to figure out how Mode Creation works to create a new HTTP TCP Mode.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 25th Oct 2010 23:45
Quote: "Off to figure out how Mode Creation works to create a new HTTP TCP Mode."

Oh I'm sure you'l have fun doing that, will be great to see someone do that .

TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 27th Oct 2010 14:38 Edited at: 27th Oct 2010 14:41
Quote: "Oh I'm sure you'l have fun doing that, will be great to see someone do that ."
It is proving to be a challenge. I'm using the MikeNet Project Source code (containing .h & .cpp) as reference and created the NetModeTcpForHTTP class that currently duplicates the NetModeTcpPostfix class. I've also added a TCP_FOR_HTTP to enum ProtocolMode.

However, the code is failing during the TCP Mode validation process which I assume is located --> NetMode::ValidateProtocolModeTCP( ProtocolMode mode ). The body of that method is a switch-case that has the ProtocolModes hardcoded. I need to add TCP_FOR_HTTP to it for the validation to be sucessful. This leads me to believe I will to recompile the MikeNet Libs, but, I'm not sure at this stage how that can be done or if its necessary.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 27th Oct 2010 15:45 Edited at: 27th Oct 2010 15:47
You can't use custom TCP modes with the mn namespace, instead you have to use the (slightly) lower level classes e.g. NetInstanceServer. If you look at the code for the mn namespace you see that this isn't very difficult.

Or, if you really want to use the mn namespace then you do have to modify MikeNet directly and recompile. The modifications are fairly minor though.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 27th Oct 2010 18:14
Also, forgot to mention:

If you are just using TCP in client state then you should use NetSocketTCP. It works similar to NetInstanceClient but without alot of extra stuff that you don't need. Its also easier to setup.

Kretaner
14
Years of Service
User Offline
Joined: 19th Oct 2010
Location: Crete, Greece
Posted: 28th Oct 2010 17:37
Hello Michael,

thanks for the help about the order of includes from last sunday.
Because my project has in the meantime over 100 different class files and I'm using a StdAfx.h in all of them, the only way was to include both there:

Unfortunatly, when I compile now I always have a Linker LNK2019 error for every using of a class from MikeNet:


(in this case mn::CreatePacket(); - sorry, the warnings are in German language).

Because I'm not a C++ guru and I'm was starting with it only because of DarkGDK, these troubles which I didn't had with the previous version of your real great Library, waste me a lot of time.

Maybe somebody has a better idea to place the includes in my hughe project ?

Thanks!

Login to post a reply

Server time is: 2024-11-21 20:14:42
Your offset time is: 2024-11-21 20:14:42