This is only one of many possible implementations and should also outline how one would create a 'Translator' and subsequently a 'TranslatedConnection'. One could obviously (or not so) outline Send and Receive methods either within the base class as well as within an interface to allow cross network communication if desired.
The class 'Connection' defines a suitable base for any type of connection. 'NetworkConnection' adds requirements for the Network, finally an 'IPNetworkConnection' to implement the logic required for the IP Protocol. This can also be extended to 'TcpNetworkConnection' and then to 'TcpIpNetworkConnection' or in any other way desired for instance 'SerialConnection' or 'EthernetConnection' and then build a class to allow the cross media communication e.g. 'SerialToEthernetNetworkConnection' inter alia.
For example:
#region Copyright
/*
This file came from Managed Media Aggregation, You can always find the latest version @ https://net7mma.codeplex.com/
Julius.Friedman@gmail.com / (SR. Software Engineer ASTI Transportation Inc. http://www.asti-trans.com)
Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction,
* including without limitation the rights to :
* use,
* copy,
* modify,
* merge,
* publish,
* distribute,
* sublicense,
* and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
*
* JuliusFriedman@gmail.com should be contacted for further details.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
*
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE,
* ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* v//
*/
#endregion
namespace Media.Sockets
{
#region TcpNetworkConnection
public class TcpNetworkConnection : NetworkConnection
{
#region Statics
public static System.Net.NetworkInformation.TcpConnectionInformation[] TcpConnectionInformation
{
get { return IPNetworkConnection.IPGlobalProperties.GetActiveTcpConnections(); }
}
#endregion
public TcpNetworkConnection(string name, bool shouldDispose) : base(name, shouldDispose) { }
}
#endregion
}
#region Copyright
/*
This file came from Managed Media Aggregation, You can always find the latest version @ https://net7mma.codeplex.com/
Julius.Friedman@gmail.com / (SR. Software Engineer ASTI Transportation Inc. http://www.asti-trans.com)
Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction,
* including without limitation the rights to :
* use,
* copy,
* modify,
* merge,
* publish,
* distribute,
* sublicense,
* and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
*
* JuliusFriedman@gmail.com should be contacted for further details.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
*
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE,
* ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* v//
*/
#endregion
namespace Media.Sockets
{
#region TcpNetworkConnection
public class TcpIPNetworkConnection : IPNetworkConnection
{
#region Statics
public static System.Net.NetworkInformation.TcpConnectionInformation[] TcpConnectionInformation
{
get { return IPNetworkConnection.IPGlobalProperties.GetActiveTcpConnections(); }
}
#endregion
public TcpIPNetworkConnection() : base(string.Empty) { }
}
#endregion
}
Are both valid implementations but serve different purposes.