Giter Club home page Giter Club logo

networkcomms.net's People

Contributors

marcfletcher avatar mattdean avatar milenastaporek avatar mufanza avatar pashcovich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

networkcomms.net's Issues

PacketHandlerErrorGlobal_File Overload

On my server, I seem to be getting bombarded by these. However, I have followed all steps accordingly and my server seems to be transferring information at high speeds with no loss. Sounds like a bug to me, but that's not my call I guess.

Message never gets received

Using breakpoints I can see that the server sends a response message, but the client never receives it.
Sample code below:

Client

class Program
{
    static void Main(string[] args)
    {
        NetworkComms.AppendGlobalIncomingPacketHandler<bool>("Response", (header, connection, message) =>
        {
            //
            //
            // MESSAGE SHOULD BE RECEIVED HERE, BUT ISN'T
            //
            //
            Console.WriteLine("\nA login response was received from " + connection.ConnectionInfo.RemoteEndPoint + " which said '" + message + "'.");
        });
        //Start listening for incoming connections
        Connection.StartListening(ConnectionType.TCP, new IPEndPoint(IPAddress.Any, 0));

        //Request server IP and port number
        Console.WriteLine("Please enter the server IP and port in the format 192.168.0.1:10000 and press return:");
        var serverInfo = Console.ReadLine();
        if (serverInfo == string.Empty) serverInfo = "127.0.0.1:2048";

        //Parse the necessary information out of the provided string
        var serverAddr = serverInfo.Split(':').First();
        var serverPort = int.Parse(serverInfo.Split(':').Last());

        //Keep a loopcounter
        var loopCounter = 1;
        while (true)
        {
            //Write some information to the console window
            var messageToSend = "Jeff";
            Console.WriteLine("Sending message to server saying '" + messageToSend + "'");

            //Send the message in a single line
            NetworkComms.SendObject("Login", serverAddr, serverPort, messageToSend);

            //Check if user wants to go around the loop
            Console.WriteLine("\nPress q to quit or any other key to send another message.");
            if (Console.ReadKey(true).Key == ConsoleKey.Q) break;
            loopCounter++;
        }

        //We have used comms so we make sure to call shutdown
        NetworkComms.Shutdown();
    }
}

Server

class Program
{
    private const int Port = 2048;

    private static readonly List<string> UserList = new List<string>();

    static void Main(string[] args)
    {
        //We expect the incoming object to be a string which we state explicitly by using <string>
        NetworkComms.AppendGlobalIncomingPacketHandler<string>("Login", (header, connection, name) =>
        {
            Console.WriteLine("\nA message was received from " + connection.ConnectionInfo.RemoteEndPoint + " who wants to be called '" + name + "'.");

            var ip = connection.ConnectionInfo.RemoteEndPoint.ToString().Split(':')[0];
            var port = int.Parse(connection.ConnectionInfo.RemoteEndPoint.ToString().Split(':')[1]);

            var allowedIn = true;
            
            for (var i = 0; i < UserList.Count; i++)
            {
                if (UserList[i] == name)
                {
                    Console.WriteLine(name + " is not allowed in since there is already a user with that name.");
                    NetworkComms.SendObject("Response", ip, port, false);
                    allowedIn = false;
                }
            }

            if (UserList.Count == 0) allowedIn = true;

            if (allowedIn)
            {
                Console.WriteLine(name + " has joined!");
                UserList.Add(name);
                //
                //
                // MESSAGE IS SENT HERE
                //
                //
                NetworkComms.SendObject("Response", ip, port, true);
            }
        });
        //Start listening for incoming connections
        Connection.StartListening(ConnectionType.TCP, new IPEndPoint(IPAddress.Any, Port));

        //Print out the IPs and ports we are now listening on
        Console.WriteLine("Server listening for TCP connection on PORT " + Port);

        while (true)
        {
            Console.Clear();
            
            Console.WriteLine("User List:");
            for (var i = 0; i < UserList.Count; i++)
            {
                Console.WriteLine("\t" + UserList[i]);
            }

            Thread.Sleep(100);
        }
        
        //We have used NetworkComms so we should ensure that we correctly call shutdown
        //NetworkComms.Shutdown();
    }
}

I'm using Win10 Pro 64-bit and VS Community 2017.

NetworkCommsDotNet.ConnectionSetupException

When I use the sample code to send data, it doesn't work and gives this exception in the message console:

NetworkCommsDotNet.ConnectionSetupException

This happens even when I have the server running.

The reason given is: Error during TCP connection establish with destination....

Client code:

try
      {
            String messageToSend = "this is a test message";
            NetworkComms.SendObject("Message", SERVER_IP, PORT_NO, messageToSend);
      }
catch (Exception e)
{
       DoGUIStatus(e.ToString().Substring(0, 160));
 }

Server code:

private void StartListening()
{
     try
     {
         NetworkComms.AppendGlobalIncomingPacketHandler<string>("Message", DisplayIncomingData);
         Connection.StartListening(ConnectionType.TCP, new System.Net.IPEndPoint(System.Net.IPAddress.Any, 0));
         DoGUIStatus("Started listening");
     }
     catch(Exception e)
     {
         DoGUIStatus(e.ToString() + "Could not start listening");
     }
 }


 private void DisplayIncomingData(PacketHeader header, Connection connection, string message)
 {
      Console.WriteLine("\nA message was received from " + connection.ToString() + " which said '" + message + "'.");
      DoGUIStatus(message);
 }

Any idea why this is happening ?? @MattDean @pashcovich

Examples Address Reuse

The current console examples allow the user to reuse the previous address by entering 'r'. We have seen some people complain on the forums that 'r:' did not work. Should be easy to accept either and will avoid future confusion.

Not an Issue but a feature request

Is there a possibility to encrypt communication using Public/Private key handshake.

  1. Client requests server for its public key. (Handshake)
  2. The client sends all its messages which includes clients public key. This message is encrypted by the server's public key.
  3. The server receives the message/request etc and decrypts it with the server's private key. Then it does it's work and sends the response to the client encrypted by the client's public key,
  4. The client receives the message and decrypts it with its private key.

This kind of encryption will remove the dependency on Pre sharing a key.

ARM Linux

With the usefulness of RaspberryPi and clones/offshoots as well as the cross platform nature of .net core these days it would be super cool if NetworkComms.net could be used on Linux.

Use case - I developed a UWP program to run on Raspberry Pi that initially ran on Windows 10 IOT and connected to a host program on a windows based computer. It uses NetworkComms.net for the host program to communicate with the RPi. Has been working great.

Since Win10 IOT was never really further developed, seems mostly abandoned, and doesn't support the plethora of hardware that Linux does, I decided to see about porting my RPi based program to Linux and .net core 7. Things were going great until I tried to open my UDP broadcast listener on the RPi. I was met with an error message:

Socket.IOControl handles Windows-specific control codes and is not supported on this platform.

In googling around a bit it seems like this is maybe related to a keepalive setting that can be set another way. In looking at the NetworkComms.net source, I only see one call to IOControl - and it's not applied to Android & iOS because the behavior is not required - could Linux be added to the clause to solve the issue for the same reason or am I running up against something else like the keepalive issue mentioned above? Below is the code snippet (code tag doesn't seem to be working properly so I'll just quote)

#if !ANDROID && !iOS
//By default we ignore ICMP destination unreachable packets so that we can continue to use the udp client even if we send something down a black hole
//This is unsupported in Mono but also not required as the same behaviour is not observed.
if (UDPConnection.IgnoreICMPDestinationUnreachable && Type.GetType("Mono.Runtime") == null)
this.udpClient.Client.IOControl(SIO_UDP_CONNRESET, new byte[] { 0, 0, 0, 0 }, new byte[] { 0, 0, 0, 0 });
#endif

UDP Broadcast not received on Raspberry Pi 3

Thanks for making this library, I like the concept!

As the title suggests: I've tried to make a UDP broadcast work on two Raspberry Pi boxes, connected to the same router as my laptop. They seemingly cannot talk to each other using NetworkComms.
There are no errors output or exceptions thrown while the application is running.

I need the Raspberrys to broadcast to each other. Is my usage of your library at fault here or do you have any pointers? How can I provide further info for debugging NetworkComms's part of things?

Versions
NetworkComms 3.0.3
Raspberrry Pi 3
.NET Framework 4.6.1
mono 4.6.2
OS: Raspbian Lite - Raspbian GNU/Linux 9 (stretch)

Source code

using NetworkCommsDotNet;
using NetworkCommsDotNet.Connections;
using NetworkCommsDotNet.Connections.UDP;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace UdpExample
{
    class Program
    {
        static void Main(string[] args)
        {
            NetworkComms.AppendGlobalIncomingPacketHandler<string>("ChatMessage",
                (packetHeader, connection, incomingString) =>
                {
                    Console.WriteLine("\n  ... Incoming message from " +
                        connection.ToString() + " saying '" +
                        incomingString + "'.");
                });

            //Start listening for incoming UDP data
            Connection.StartListening(ConnectionType.UDP, new IPEndPoint(IPAddress.Any, 10000));

            Console.WriteLine("Type ESC to quit.");
            do
            {
                while (!Console.KeyAvailable)
                {

                    UDPConnection.SendObject("ChatMessage", "This is the broadcast test message!", new IPEndPoint(IPAddress.Broadcast, 10000));

                    Task.Delay(2000).Wait();
                }
            } while (Console.ReadKey(true).Key != ConsoleKey.Escape);

            NetworkComms.Shutdown();
        }
    }
}

SSH Session
When starting the program on two raspberries, they don't receive messages (console window does not print the received ChatMessage):
20181113-1-udp-10000 ssh-session

Wireshark sees broadcasts
Meanwhile... the broadcasts can be seen in Wireshark:
20181113-1-udp-10000 wireshark

Netcat works
A netcat session reveals that send/receive should work, so it's not likely a configuration issue:
20181113-1-udp-10000 netcat

Thanks in advance!

Possible Bug when trying to reconnect with unmanaged connection

Hi,

I might have found a possible bug when trying to reconnect with an unmanaged connection.

First I create my unmanaged connection:

SendReceiveOptions optionsToUse = new SendReceiveOptions<NullSerializer>();
ConnectionInfo connectionInfo = new ConnectionInfo("192.168.0.2", 10001, ApplicationLayerProtocolStatus.Disabled);

var conn = TCPConnection.GetConnection(connectionInfo, optionsToUse);

After this I check the conn.ConnectionInfo.ConnectionState to see if it is ConnectionState.Established.

Here is my testing scenario:

  1. Start application
  2. Ethernet cable plugged in - ConnectionState is Established
  3. Ethernet cable is removed, a timer will create a new connection after 1 minute - ConnectionState is still Established.

Am I using the ConnectionState incorrectly?

Update:
If you do not use the CloseConnection method before creating the new connection it will use the last ConnectionInfo for the IP / Port. Not sure if this is still a bug, for now everything seems fine.

Kind Regards,
JP

How to disable error files

We have a large central application using the libraries and couple hundreds computer has a remote viewer app that all it does is listen to the server events and display data. It's only incoming data. But the same application create a bunch a txt error files beside the exe and flood the folder overtime. I am wondering how we can disable all these file creation. The software works perfectly on these computers there is no issue whatsoever other than those annoying files.

I need to mention that this issue don't happen on all computers. It's about 50/50.

name of the files are starting with these names :
ManagedThreadPoolCallBackError
CompleteIncomingItemTaskError
PacketHandlerErrorGlobal_Notification

We tried using the following without success.
NetworkComms.DisableLogging();

It's not a big issue, we can code something to check for those file name and delete but i was looking for a cleaner solution.

Networkcomms for iOS inside of Unity not working

Hey,

I can't get Networkcomms to work inside Unity on a iOS platform.
What is the difference between the Networkcomms.IOS version and the .net 3.5?
What makes the one work in iOS and the other not?

I tried to include the Networkcomms.IOS in Unity but it can't refactor it due to the 4.5 framework.
I tried to compile a 3.5 version of Networkcomms.IOS but that did not work either as the Xamarin.IOS library is missing.

ObjectDisposedException in System.Threading.ManualResetEvent (Xamarin Android)

When trying to connect to invalid host:

try {
ConnectionInfo connInfo = new ConnectionInfo(InvalidHostAddress);
Connection newTCPConn = TCPConnection.GetConnection(connInfo);
Connection = newTCPConn;
} catch() {}

got this exception and app crash

Stack trace:

>   0x2F in System.Net.Sockets.SocketAsyncResult.set_IsCompleted at /Users/builder/data/lanes/3236/ee215fc9/source/mono/mcs/class/System/System.Net.Sockets/SocketAsyncResult.cs:122,7  C#
    0x39 in System.Net.Sockets.SocketAsyncResult.Complete at /Users/builder/data/lanes/3236/ee215fc9/source/mono/mcs/class/System/System.Net.Sockets/SocketAsyncResult.cs:226,4 C#
    0x8 in System.Net.Sockets.SocketAsyncResult.Complete at /Users/builder/data/lanes/3236/ee215fc9/source/mono/mcs/class/System/System.Net.Sockets/SocketAsyncResult.cs:289,4  C#
    0x194 in System.Net.Sockets.SocketAsyncWorker.Connect at /Users/builder/data/lanes/3236/ee215fc9/source/mono/mcs/class/System/System.Net.Sockets/SocketAsyncWorker.cs:256,5 C#
    0x90 in System.Net.Sockets.SocketAsyncWorker.DispatcherCB at /Users/builder/data/lanes/3236/ee215fc9/source/mono/mcs/class/System/System.Net.Sockets/SocketAsyncWorker.cs:80,5  C#
    0x6 in System.Net.Sockets.SocketAsyncResult.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem at /Users/builder/data/lanes/3236/ee215fc9/source/mono/mcs/class/System/System.Net.Sockets/SocketAsyncResult.cs:307,4  C#

Connection level Checksum Configuration

Currently if you want to enable checksum it can only be done at the global level:
NetworkComms.EnablePacketCheckSumValidation

We should move this into the SendRecieveOptions so that it can be done on a per send/receive basis:
SendReceiveOptions.EnablePacketCheckSumValidation

Dead lock with bad locking.

SendPacket can cause RemoveConnectionReference and AddConnectionReference can call SendPacket.
The first takes sendLocker then globalDictAndDelegateLocker, the second takes them in reverse.

NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.Connections.Connection.SendPacket<byte[]>(NetworkCommsDotNet.IPacket packet, out long packetSequenceNumber) Line 527	 
NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.Connections.Connection.SendReceiveObject<byte[], byte[]>(string sendingPacketTypeStr, string expectedReturnPacketTypeStr, int returnPacketTimeOutMilliSeconds, byte[] sendObject, NetworkCommsDotNet.SendReceiveOptions sendOptions, NetworkCommsDotNet.SendReceiveOptions receiveOptions, out long sentPacketSequenceNumber) Line 256	 
NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.Connections.Connection.ConnectionAlive(int aliveRespondTimeoutMS, out long responseTimeMS) Line 474	 
NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.Connections.Connection.ConnectionAlive() Line 428	 
NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.NetworkComms.AddConnectionReferenceByRemoteEndPoint(NetworkCommsDotNet.Connections.Connection connection, System.Net.EndPoint remoteEndPointToUse, System.Net.EndPoint localEndPointToUse) Line 1897	 
NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.NetworkComms.UpdateConnectionReferenceByEndPoint(NetworkCommsDotNet.Connections.Connection connection, System.Net.EndPoint newRemoteEndPoint, System.Net.EndPoint newLocalEndPoint) Line 1985	 
NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.Connections.Connection.ConnectionSetupHandlerFinal(NetworkCommsDotNet.ConnectionInfo remoteConnectionInfo, ref bool possibleClashWithExistingConnection, ref NetworkCommsDotNet.Connections.Connection existingConnection) Line 488	 
NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.Connections.Connection.ConnectionSetupHandler(System.IO.MemoryStream packetDataSection) Line 343	 
NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.NetworkComms.CompleteIncomingItemTask(object priorityQueueItemObj) Line 334	 
NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.Connections.Connection.IncomingPacketHandleHandOff(NetworkCommsDotNet.Tools.PacketBuilder packetBuilder) Line 163	 
NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.Connections.TCP.TCPConnection.IncomingTCPPacketHandler(System.IAsyncResult ar) Line 405	 

NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.NetworkComms.RemoveConnectionReference(NetworkCommsDotNet.Connections.Connection connection, bool maintainConnectionInfoHistory) Line 1809	 
NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.Connections.Connection.CloseConnection(bool closeDueToError, int logLocation) Line 369	 
NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.Connections.Connection.SendPacket<object>(NetworkCommsDotNet.IPacket packet, out long packetSequenceNumber) Line 659	 
NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.Connections.Connection.SendReceiveObject<object, string[]>(string sendingPacketTypeStr, string expectedReturnPacketTypeStr, int returnPacketTimeOutMilliSeconds, object sendObject, NetworkCommsDotNet.SendReceiveOptions sendOptions, NetworkCommsDotNet.SendReceiveOptions receiveOptions, out long sentPacketSequenceNumber) Line 256	 
NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.Connections.Connection.SendReceiveObject<object, string[]>(string sendingPacketTypeStr, string expectedReturnPacketTypeStr, int returnPacketTimeOutMilliSeconds, object sendObject, NetworkCommsDotNet.SendReceiveOptions sendOptions, NetworkCommsDotNet.SendReceiveOptions receiveOptions) Line 201	 
NetworkCommsDotNetComplete.dll!NetworkCommsDotNet.Connections.Connection.SendReceiveObject<string[]>(string sendingPacketTypeStr, string expectedReturnPacketTypeStr, int returnPacketTimeOutMilliSeconds) Line 298	 

Num. of Packet Handlers

We don't have any global or connection specific overrides that allows you to quickly determine the number of configured packet handlers.

Bluetooth Example

We need a bluetooth example project. A corresponding article for the website would also be great to help add some more recent tutorials.

Throw exception on a network card manually assigned ip address with unplugged state when enable local server

NetworkCommsDotNet.CommsSetupShutdownException
HResult=0x80131500
Message=It was not possible to open port #0 on 192.168.137.1. This endPoint may not support listening or possibly try again using a different port.
Source=NetworkCommsDotNet
StackTrace:
at NetworkCommsDotNet.Connections.TCP.TCPConnectionListener.StartListening(EndPoint desiredLocalListenEndPoint, Boolean useRandomPortFailOver) in D:\Downloads\NetworkComms.Net-master\NetworkComms.Net-master\NetworkCommsDotNet\Connection\TCP\TCPConnectionListener.cs:line 146
at NetworkCommsDotNet.Connections.Connection.StartListening[T](ConnectionListenerBase listener, T desiredLocalEndPoint, Boolean useRandomPortFailOver) in D:\Downloads\NetworkComms.Net-master\NetworkComms.Net-master\NetworkCommsDotNet\Connection\ConnectionListeners.cs:line 193
at NetworkCommsDotNet.Connections.Connection.StartListening[T](ConnectionType connectionType, T desiredLocalEndPoint, Boolean allowDiscoverable) in D:\Downloads\NetworkComms.Net-master\NetworkComms.Net-master\NetworkCommsDotNet\Connection\ConnectionListeners.cs:line 110
at Examples.ExamplesChat.WPF.ChatAppBase.RefreshNetworkCommsConfiguration() in D:\Downloads\NetworkComms.Net-master\NetworkComms.Net-master\ExamplesChat.WPF\ChatAppBase.cs:line 190
at Examples.ExamplesChat.WPF.MainWindow.EnableLocalServer_CheckedUnChecked(Object sender, RoutedEventArgs e) in D:\Downloads\NetworkComms.Net-master\NetworkComms.Net-master\ExamplesChat.WPF\MainWindow.xaml.cs:line 155
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.Controls.Primitives.ToggleButton.OnIsCheckedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetCurrentValueInternal(DependencyProperty dp, Object value)
at System.Windows.Controls.Primitives.ToggleButton.OnToggle()
at System.Windows.Controls.Primitives.ToggleButton.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at ExamplesWPFChat.App.Main()

Connection Close Handlers

Right now connection close handlers only take a single argument, the connection being closed.
We could extend these to also take an optional trace number and whether the connection was closed due to an exception (i.e. in the same way that Connection.CloseConnection does).

IExplicitSerializer doesn't work with custom classes

Hi,

Thanks for the hard work & the amazing library! Works great most of the time, though I believe I found a bug in the ExplicitSerialzier

Version: 3.0.4.1
Situation: Trying to send custom classes and deserialize them with ExplicitSerializer closes the connection abruptly. No error message is shown. The 'Deserialize' method of the IExplicitlySerialize interface doesn't seem to get called ('Serialize' seems to pass correctly). Sending primitive types/arrays works correctly.

Example:
The following example implements a custom ExplicitModel class. For simplicity's sake, the Serialize and Deserialize methods were left empty (so we'd expect a default instance to pop on the server side, regardless of whatever data the client sends over)

public class ExplicitModel : IExplicitlySerialize
{
    int Id { get; set; }
    string Name { get; set; }

    public ExplicitModel() { }
    public void Serialize(Stream outputStream) { }
    public void Deserialize(Stream inputStream) { }
}

public ServerApp()
{
    var options = new SendReceiveOptions<ExplicitSerializer>();
    NetworkComms.AppendGlobalIncomingPacketHandler<ExplicitModel>("ExplicitModel", ReceiveExplicitModel, options);
    var connectionsTCP = Connection.StartListening
    (
        ConnectionType.TCP,
        new System.Net.IPEndPoint(System.Net.IPAddress.Any, 8754)
    );
    Console.ReadKey();
}

private static void ReceiveExplicitModel(PacketHeader header, Connection connection, ExplicitModel model) =>
    Console.WriteLine($"Received model explicitly");

public ClientApp()
{
    var options = new SendReceiveOptions<ExplicitSerializer>();
    var connection = TCPConnection.GetConnection(new ConnectionInfo("127.0.0.1", 8754));
    var model = new ExplicitModel() { Id = 5, Name = "Foo" }
    connection.SendObject<ExplicitModel>("ExplicitModel", model, options);
    Console.ReadKey();
}

TCP: Receiving packet in Xamarin.iOS

NetworkComms.Net Version: 3.0.3
When trying to receive an object by either using NetworkComms AppendGlobalIncomingPacketHandler or SendReceiveObject in Xamarin.iOS it crashes with System.NotSupportedException error.
Using the same code in a WinForms application works perfectly fine.

`		public static void TestNMEA()
	{
		NetworkComms.AppendGlobalIncomingPacketHandler<string>("ResponseGPSCoordinates", PrintIncomingMessage);

		NetworkComms.SendObject("RequestGPSCoordinates", "192.168.1.80", 50000, "Hello Worldas");
		//var result = NetworkComms.SendReceiveObject<string, string>("RequestGPSCoordinates", "192.168.1.80", 50000, "ResponseGPSCoordinates", 500000, "Hello");
	}

	private static void PrintIncomingMessage(PacketHeader header, Connection connection, string message)
	{
		Debug.WriteLine("\nA message was received from " + connection.ToString() + " which said '" + message + "'.");
	}

`

screen shot 2017-07-20 at 13 30 43

Possible Issue with Examples in Visual Studio 2015

Hi,

I am trying to use the examples provided in Visual Studio 2015, however I keep getting the following error:

Specified cast is not valid.

Here is the screenshot:

image

The examples work fine in Visual Studio 2012.

Custom Protocol Support

Abstract out the current networkcomms.net application layer protocol so that support could be easily added for others that have been requested in the parts:

  • HTTP(S)
  • Web Socket

Get a file from local network folder

Hello,

Just getting started with NetworkComms. I wanted to know if there is a way to get specific file types (.txt, .bmp, etc.) from a local network folder. Essentially my app will be polling this folder and as soon as a file is dropped into that folder, I will need to transfer the file from the network folder to the host PC local directory.

Thanks!

AK

Having an issue with EnableDiscoverable

Hi,

First of all, thank you for sharing such a wonderful library.

I am having an issue with this code.

HostInfo.IP.RestrictLocalAddressRanges = new IPRange[] { new IPRange(txtRangeStart.Text), new IPRange(txtRangeEnd.Text) }; PeerDiscovery.EnableDiscoverable(PeerDiscovery.DiscoveryMethod.UDPBroadcast);

I am supplying Range Start as 127.0.01/32 and 192.168.2.0/32. The IP of current PC is 192.168.1.40. The other Peer is running on 192.168.2.35.

But this Peer is always failing at start when it reach the above mentioned portion of the code saying "Failed to find local available port on address 192.168.2.69 while trying to make this peer discoverable. Consider increasing the available port range via MinTargetLocalIPPort and MaxTragetLocalIPPort."

But strange is that 192.168.2.69 is not being used by any other PC in network. It's unused IP in that network. If I specifically use this IP in end range using 192.168.2.69/32, it generates same error. Also 192.168.2.68 is another unused IP in the network. But if I specify end range as 192.168.2.68/32 it does not reflect same issue, it works fine. Problem only occurring when 192.168.2.69 IP comes across in range or specifically set.

Can you please help me? Thanks in advance.

.Net Core support

Hello,

Are there any plans to support .net core for this library?
If this is in place, it can be a really good alternative to WCF, as they are not planning to have that.

.Net MAUI support

Hi all!

Loving your library, it's made it super easy to handle a server/client subscriber model in my WPF application. I went down this path due to the promise of being able to use it in IOS to talk to the same WPF app, and with MAUI coming out recently I've started to dabble there... Any plans to lift this up to MAUI?

Thanks

Jeff

Custom message framing

Hi, thanks for this wonderful project. I was hoping to use it in my application for its high networking performance and some abstraction from thready safety issues.

However, looking at the API and the tutorials, it seems that the library relies on PacketHeader and the like to implement its own message framing/serialization. How do I bypass that to implement a custom protocol that uses simple length prefixing instead? Any help would be appreciated.

RPC : Generic Parent Service Interface

//Common Interfaces

public interface ISettingsService : IBaseService
{
Settings GetBy_SettingName(string settingName);
}
public interface IBaseService where T : IProtoBuffEntity
{
bool Delete(T entity);
bool Create(T entity);
bool Update(T entity);
IList GetAll(int recordsPerPage, int pageNumber);
int GetRecordsCount();
}

//Above ISettingsService is an interface which is mapped to a service on the server
//ClinetProxyCreation where T is ISettingsService
remoteObject = RemoteProcedureCalls.Client.CreateProxyToPrivateInstance(connection, "ISettingsService".ToLower(), out instanceId);

I get following error on client side
The type initializer for 'Cache1' threw an exception.The type initializer for ' Cache1' threw an exception.
System.TypeLoadException: Method 'Delete' in type
'XXXX.ServerModules.grp_ISettingsService'

Sending List<CustomObject> not possible

how do you send a List?

i tried it already and implemented IExplicitlySerialize on CustomObject and realized that List should also implement it, should i extend the List Class?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.