UDP socket shared on multiple page

sébastien DECORME 26 Reputation points
2021-03-11T13:30:53.33+00:00

Hi,
I would like to make an UWP and android application to communicate with an UDP server.
On the first page I've a connected button to launch the connexion with the server.
I've multiple page with Request button on each.
I selected a page and I click on the request button it will will update Entry or Label with informations received by UDP.
How can I send UDP packet when I click on a request(One unique packet by button) to my UDP class instancied on the first page ?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,325 questions
Universal Windows Platform (UWP)
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Nico Zhu (Shanghai Wicresoft Co,.Ltd.) 12,861 Reputation points
    2021-03-12T03:09:06.853+00:00

    Hello, Welcome to Micorosoft Q&A,

    UDP socket shared on multiple page

    In general, we could use CoreApplication.Properties dictionary to store this socket instance and get it with the key in UWP platform, And Xamarin Forms has same method Application.Current.Properties dictionary that could pass the value.

    For example

     Application.Current.Properties["socket"] = socket;  
    

    Retrieve Instance

     var socket = Application.Current.Properties["socket"] as Socket;  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments