Home Forums Support client-server to exchange files (like in p2p?)

Tagged: ,

  • This topic has 26 replies, 2 voices, and was last updated 9 years ago by Anonymous.
Viewing 10 posts - 11 through 20 (of 27 total)
  • Author
    Posts
  • #968
    Anonymous
    Inactive

    Sorry for typos ….. I would mean if there is any advanced piece of code on how to retrive a device lists (ips) with UDP broadcast.
    Thanks

    #969
    Anonymous
    Inactive

    I’m doing trivial connection tests on Networkcomm libary.
    I just done into an Activity:

    protected override void OnCreate (Bundle bundle)
    		{
    			base.OnCreate (bundle);
    
    			// Set our view from the "main" layout resource
    			SetContentView (Resource.Layout.Main);
    			//
    
    			// Get our button from the layout resource,
    			// and attach an event to it
    			Button button = FindViewById<Button> (Resource.Id.myButton);
    			
    			button.Click += delegate {
    				button.Text = string.Format ("{0} clicks!", count++);
    				try
    				{
    					UDPConnection.SendObject("ChatMessage",
    					                         "This is the broadcast test message!",
    					                         new IPEndPoint(IPAddress.Broadcast, 10000));
    				}
    				catch (System.NotSupportedException err1) { 
    					Console.WriteLine(err1.Message);
    				}
    				catch (CommsException err2) {
    					Console.WriteLine(err2.Message);
    				}
    				catch (Exception err3)   {
    
    					Console.WriteLine(err3.Message);
    				}
    
    			};
    
    			NetworkComms.AppendGlobalIncomingPacketHandler<string>("ChatMessage",
    			                                                       (packetHeader, connection, incomingString) =>
    			                                                       {
    				Console.WriteLine("\n  ... Incoming message from " +
    				                  connection.ToString() + " saying '" +
    				                  incomingString + "'.");
    
    			});
    
    			//Start listening for incoming UDP data
    			UDPConnection.StartListening(true);
    
    		}
    
    			
    		
    	}

    On the button click event I send a bradcast message. I’ve installed the same App in two devices who are on my net (tested with your chat samples and are working). Just in the first I click on button expecting in the second app which is listening something happen, but in the AppendGlobalIncomingPacketHandler the debugger never pass through ….. Where Do I’m wrong ?
    Thanks,
    Max

    #970
    Anonymous
    Inactive

    After calling:

     UDPConnection.StartListening(true);

    Check UDPConnection.ExistingLocalListenEndPoints() to confirm you are listening on port 10000.

    #971
    Anonymous
    Inactive

    Already done! There is any possibility the broadcast messages are not compatible with the wifi router ?

    #972
    Anonymous
    Inactive

    Are both of your devices on the same network subnet? Most routers should be configured by default to allow broadcasts within the same subnet but it is worth confirming. If you still have problems I may mockup an example for you to test.

    #973
    Anonymous
    Inactive

    Yes devices are in the same subnet 192.168.1.0
    If I call directly with tcp they communicate.
    Thanks an example will be much appreciated.
    Greetings
    Max

    #974
    Anonymous
    Inactive

    I can report this:
    Base Exception Type: System.Net.Sockets.SocketException: Access denied
    at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0
    at NetworkCommsDotNet.NetworkComms.BestLocalEndPoint (System.Net.IPEndPoint remoteIPEndPoint) [0x00000] in <filename unknown>:0
    at NetworkCommsDotNet.UDPConnection.SendObject (System.String sendingPacketType, System.Object objectToSend, System.Net.IPEndPoint ipEndPoint, NetworkCommsDotNet.SendReceiveOptions sendReceiveOptions) [0x00000] in <filename unknown>:0

    Stack Trace: at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0
    at NetworkCommsDotNet.NetworkComms.BestLocalEndPoint (System.Net.IPEndPoint remoteIPEndPoint) [0x00000] in <filename unknown>:0
    at NetworkCommsDotNet.UDPConnection.SendObject (System.String sendingPacketType, System.Object objectToSend, System.Net.IPEndPoint ipEndPoint, NetworkCommsDotNet.SendReceiveOptions sendReceiveOptions) [0x00000] in <filename unknown>:0
    THe Internet permission is checked on manfest file.

    #975
    Anonymous
    Inactive

    Interesting. Has this exception been happening all along?

    #976
    Anonymous
    Inactive

    It happens everytime I try to send broadcast message.

    #977
    Anonymous
    Inactive

    This sounds like a bug with the xamarin side of things, we will continue to investigate but because the bug is not with our code this might take a little longer. Please see the following bug https://bugzilla.xamarin.com/show_bug.cgi?id=2162. It suggest setting some application flags which might help resolve the problem.

Viewing 10 posts - 11 through 20 (of 27 total)
  • You must be logged in to reply to this topic.