20 Apr, 2010, Elgatodefuego wrote in the 1st comment:
Votes: 0
Hello everyone! I've currently going through school for Game Design in XNA and one of our projects is in Multi-player Server design. Anyway, my project is currently centered around a MUD server in C#. I've gotten everything built and the game is semi playable but in order to build a well rounded server I wanted to add MCCP. I've read up on the RFC 1950 and I believe that after passing through the initial handshaking and option negotiation I'm handling the output right (it sets a flag on the Player variable and everything that's sent then passes through a compress function where deflate is called on the chat Player's zstream).

I'm running into one of two problems now though. After the first string is sent to (it displays properly) everything else that displays is garbage characters. Or the client doesn't display anything (despite being compressed properly I believe). I was speaking with a member whom suggested I follow the Zstream to check for any non compressed characters being inserted but I did that and, after wading through A LOT of zlib garbage =D, I didn't find anything.

So I thought I would see if the MUD community could offer any advice on where to look, or possibly a working MCCP implementation in a C# codebase I could examine (Google's yet to return one).
20 Apr, 2010, Scandum wrote in the 2nd comment:
Votes: 0
Make sure you preserve the player's zstream, and keep compressing on the same stream, instead of creating a new stream for each message.

Another common error is pending telnet negotiations being transmitted uncompressed, easiest is to pass all output through the same central function that handles compression.

The last possibility is alteration of the data after it has been compressed.
21 Apr, 2010, Elgatodefuego wrote in the 3rd comment:
Votes: 0
I believe I am preserving the stream properly. Once the character's MCCP flag is set to true all output is sent through a compression call which performs the writing to deflate. Below is the final negation code (MCCP is the last to be sent) and the Compression call. I have a couple debug calls in the compression protocol to ensure the data is being compressed properly (comparing the lengths of entering and exiting data). I'm wondering if it might be my implementation of the Zlib? I'm using a third party one that says it's RFC 1950 compliant, but I'm thinking it might be better just to download the Zlib dll and make a bunch of DLL calls since I can't seem to figure out this one properly.

if (dataStream[1] == (byte)Codes.DO && dataStream[2] == (byte)Codes.COMPRESS2)
ch.Send(new byte[] { (byte)Codes.IAC, (byte)Codes.SB, (byte)Codes.COMPRESS2, (byte)Codes.IAC, (byte)Codes.SE });
ch.MCCP = true;
ch.OutputStream = new MemoryStream();
ch.ZippedStream = new ZlibStream(ch.OutputStream, CompressionMode.Compress, CompressionLevel.BestCompression);
return true;

public static byte[] Compress(CharData ch, byte[] comp)
Global.Add_Log_Entry(0, "Entering data: " + comp.Length.ToString());
Global.Add_Log_Entry(0, "Compress Called: " + Encoding.UTF8.GetString(comp));

ch.ZippedStream.Write(comp, 0, comp.Length);

byte[] rByte = ch.OutputStream.ToArray();

Global.Add_Log_Entry(0, "Exiting data: " + rByte.Length.ToString());
return rByte;
31 Jul, 2010, David Haley wrote in the 4th comment:
Votes: 0
Could this post be relevant?