Shornokishoree Network Foundation
Adolescent Health Network of Bangladesh
If you're reading this article, you've probably already seen the countless .Net TCP socket server articles on CodeProject. What I haven't found is an open source solution that is fast and efficient, easily extendable, includes security and includes an API for Android, iOS, Windows Phone, Windows, Mac and Java clients.
This article showcases an open source project I created called DotNetOpenServer SDK. The SDK provides a client/server application framework that implements an extendable binary protocol stack, supports SSL/TLS 1.2 connections, includes an extendable security framework, includes a keep-alive/heartbeat protocol and includes a C# API for Windows and Windows Mobile, a Java API for Android and Unix/Linux flavors and an Objective-C API for iOS and Mac.
There are already many articles on CodeProject that show developers how to create both synchronous and asynchronous TCP client/server applications. This article does not attempt to recreate what has already been done so well. Instead this article provides a high level overview of the framework, details the framework's binary protocol stack, summarizes how to extend the framework with protocol implementations, summarizes how to create your own authentication protocol and provides a detailed tutorial to create your own client/server application.
The complete source code for the DotNetOpenServer along with the samples created in this article can be downloaded from GitHub here:https://github.com/UpperSetting/DotNetOpenServerSDK
The Windows binaries can be downloaded from NuGet. For more information see the README.md located on GitHub here:https://github.com/UpperSetting/DotNetOpenServerSDK/blob/master/README.md
The Java JAR files and Objective-C source code can be downloaded from GitHub here:https://github.com/UpperSetting/DotNetOpenServerSDK/releases
The Windows server and client optionally support logging through log4Net which can be downloaded from NuGet here:https://www.nuget.org/packages/log4net/
To minimize the code base I auto-generated the Objective-C API from my Java source code using the J2ObjC open source project (http://j2objc.org/). At this time the J2ObjC open source project does not yet support SSL/TLS 1.2 but, according to the project owner, it is being worked on and should be released in the near future.
The documentation for the DotNetOpenServer is located here:http://www.UpperSetting.com/docs/DotNetOpenServerSDK
DotNetOpenServer is implemented on Windows using the .Net Framework 4.5.2. The server is implemented as an asynchronous TCP socket server. .Net components are used to negotiate SSL/TLS 1.2. Protocols are implemented in stand-alone assemblies which, when requested by the client, are loaded using Reflection. The information required for the server to load the assemblies is contained within the app.config file or can optionally be programatically set.
When I built this API my goal was to minimize duplicate code as much as possible. What I ended up with was several solutions and even more projects. At the lowest level is a Portable project called OpenServerShared that is shared by the server, Windows client and Windows Mobile client. Next lies a Windows project called OpenServerWindowsShared that is shared between the server and Windows client. Finally, there is a project for the server, Windows client and Windows Mobile client.