- This topic has 26 replies, 2 voices, and was last updated 11 years, 5 months ago by
Anonymous.
-
AuthorPosts
-
July 18, 2013 at 16:13 #968
Anonymous
InactiveSorry for typos ….. I would mean if there is any advanced piece of code on how to retrive a device lists (ips) with UDP broadcast.
ThanksJuly 18, 2013 at 18:46 #969Anonymous
InactiveI’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,
MaxJuly 18, 2013 at 22:51 #970Anonymous
InactiveAfter calling:
UDPConnection.StartListening(true);
Check
UDPConnection.ExistingLocalListenEndPoints()
to confirm you are listening on port 10000.July 19, 2013 at 09:57 #971Anonymous
InactiveAlready done! There is any possibility the broadcast messages are not compatible with the wifi router ?
July 19, 2013 at 10:20 #972Anonymous
InactiveAre 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.
July 19, 2013 at 11:55 #973Anonymous
InactiveYes 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
MaxJuly 19, 2013 at 16:21 #974Anonymous
InactiveI 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>:0Stack 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.July 20, 2013 at 08:42 #975Anonymous
InactiveInteresting. Has this exception been happening all along?
July 20, 2013 at 09:57 #976Anonymous
InactiveIt happens everytime I try to send broadcast message.
July 20, 2013 at 10:26 #977Anonymous
InactiveThis 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.
-
AuthorPosts
- You must be logged in to reply to this topic.