GDI+ .NET Framework
If you've been over to the "
my websites section" you'd have noticed a website / project called
Knights Tour.
Well this was my first attempt at doing GDI+ and I was simply amazed how powerful
this library can be. Naturally being a web based developer, I was thinking up ways
to utilize this. I could think up loads of ways of using this in a windows application,
but not many using for a webapp. I was tempted at using it for a fancy dynamic button
control but that didn't really seem worth while and would the performance be a problem?
I remembered a simple game I played a few months ago and decided this would be a
prime candidate for converting into a webapp using GDI+.
Another thing I decided to do whist working with GDI+ was to create a tool to quickly covert
RGB into HEX.
Secure Sockets Connection
I've recently been working on a client / server project which required communication over a custom port. In this case it was 700. Easy I thought, I'll simply use the System.Net.Sockets namespace create a socket connection and off we go.
Well things didn't workout that easy. The port required SSL which I couldn't find much documentation about. All SSL communication information I could find was all about HttpWebRequests etc... I then looked more into the framework and came across SSLStream, which can be used in conjunction with TcpClient.
Here is my successful Connect method using SSL:
public void Main()
{
client = new TcpClient( Program.AppSettings.EppHost, Program.AppSettings.EppPort);
// Create an SSL stream that will close the client's stream.
sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);
sslStream.AuthenticateAsClient(Program.AppSettings.EppHost);
// Do comms here
sslStream.Close();
client.Close();
}
private bool ValidateServerCertificate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors policyErrors)
{
if (policyErrors == SslPolicyErrors.None)
return true;
else
{
// specific error can be found in policyErrors enum;
return false;
}
}