We hope the following tutorial helps get you up and running as quickly as possible. If you feel something is missing or confusing please leave a comment below. If this tutorial is not exactly what you were after please see our tutorials section for more information.
Video equivalent of this article:
What you need to get up and running:
- Visual Studio 2010 Express or better (Including .Net4).
- The latest stable release of NetworkComms.Net, source ZIP bundle version. See our Download section.
Once you have everything you need you probably want to start working your way through the included examples. Please follow these steps or see our equivalent ‘ Getting Started Video ‘:
Part 1 – Compile the examples …
- Extract the downloaded zip file to a suitable location.
- Browser to the location chosen in step 1 and open the solution file (NetworkCommsDotNet.sln). This should open in Visual Studio. Note: You may see an error message relating to ” Documentation.shfbproj ” as a consequence of missing necessary pre-requisites, you can safely ignore this message and click OK.
- Compile all projects by hitting F6 or right clicking on the solution within Visual Studio’s Solution Explorer Window and select ‘Build Solution’. This creates the necessary project executables.
Part 2 – Run the basic example …
- You can run the examples on the same computer or across different ones. For the sake of this demonstration we will run them both locally (Just make the appropriate IP change when requested if running on different computers).
- Browse to the location where you extracted the solution in Part 1. Now browse to “ExamplesConsole\bin\Debug\” . This directory should contain the executables compiled in Part 1. If not make sure Visual Studio is configured to build Debug.
- Execute “ExamplesConsole.exe”. This should open in a new console window. Run the basic example by selecting option ’1′.
- The output of the console should be reset and now start with a line saying “Listening for messages on:” . What follows is a list of all IPs detected on the local machine and the port number now opened by the example. You may be presented with various firewall messages asking if you trust the application to open the desired port, ensure you DO give the necessary permission.
- You now need to open a second instance of “ExamplesConsole.exe”. This can be on the same machine or different. Make sure you select the basic example again using option ’1′.
- The output of the second instance should again start with “Listening for messages on:” . If you have run the second instance on the same machine note that the listening port (the bit after the colon) will now not be the default.
- You can now send messages from one instance to the other using NetworkComms.Net. In the instance of your choice type a message as directed and press return.
- Enter the IP address and port of the destination instance. This should be in the form IPAddress:Port, e.g. 192.168.1.56:10000.
- Press enter and hopefully the message appears in the destination instance.
- Look at the source code to see how short the example actually is ( online source ).
- Bear in mind it is possible to break the basic example. No error handling was included to help keep things as short as possible.
Part 3 – Run the other examples and discover the more advanced features available …
- Execute “ExamplesConsole.exe” as in part 2 and following directions provided when the other examples are selected. If you have any problems see here .
Projects in NetworkComms.Net:
Note: To support multiple platforms the solution layout changed to the following with the release of v2.2.0.
To keep the visual studio solution organised, ‘solution’ folders have been used. These are ‘virtual’ folders which do not always reflect the underlying file/folder structure. The following layout is provided as presented in the visual studio solution:
- ExamplesConsole – A number of console based examples written in C#, from the basic (BasicSend), through too advanced (AdvancedSend, Distributed File System, Remote Procedure Calls etc).
- ExamplesConsole.VB – A number of console based examples written in VB.Net. At the present time only the BasicSend example is available.
- ExamplesWPFChat – A WPF client server chat example that demonstrates the majority of features, i.e. TCP, UDP, Encryption etc.
- ExamplesWP8Chat – This is the ported version of the WPF chat application to windows phone 8. Both chat applications are compatible with one another.
The vast majority of NetworkComms.Net has been rewritten to be compatible with .Net2.0. You will find most of the actual source code within this folder.
- NetworkCommsDotNet – Where the magic happens.
- DPSBase – Defines and implements interfaces, used by NetworkCommsDotNet, for serialising, compressing and encrypting objects into bytes. Uses protobuf-net , a superior serializing tool.
- SevenZipLZMACompressor – A compression library based on the LZMA algorithm
- DLL – This folder contains the two external libraries used by NetworkComms.Net, NLog and protobuf-net, compiled for .Net 2.0
- QuickLZCompressor – A compression library based on the QuickLZ algorithm.
- SharpZipLibCompressor – A compression library based on the GZip algorithm.
In order to support multiple platforms but avoid code duplication all source code files from the .Net 20 folder are referenced within the .Net 35 solution folder.
In order to support multiple platforms but avoid code duplication all source code files from the .Net 20 folder are referenced within the .Net 40 solution folder. There are some additional extensions which are only included in the .Net 40 builds:
- Distributed File System – A torrent like system built using NetworkComms.Net. i.e. Distributes large files across a swarm of peers as fast as possible.
- RemoteProcedureCalls – Allows quick implementation of RPC classes and calls. i.e. Create local objects whose implementation is actually executed on a non local object.
WP8, Xamarin .Android & Xamarin.iOS:
In order to support multiple platforms but avoid code duplication all source code files from the above .Net folders are referenced within these mobile platform solution folders.
- Solution Items – This contains references to licensing notices, readmes etc.
- SingleDLLBuild – A project which merges all selected project DLLs into a single file during build.
- Documentation – Used to create the API documentation files. Requires SandCastle installed to open.
- DebugTests – A scratch work space for debugging issues and bugs. Just ignore this.
You first source of help should be the forums , it may well be someone else has experienced and solved a similar problem before. If you have found a genuine error please fill out a bug report here . We also offer commercial support packages.