0

I've implemented a Xamarin app that successfully peers to another instance of itself running on another device using WiFiP2PManager, OnPeersAvailable and OnConnectionInfoAvailable (etc.).

My challenge now is I'd like the group owner to specify the PORT the client(s) will use to connect.

SERVER

        var serverSocket = new ServerSocket(port); <<< PASS THIS PORT NUMBER TO THE CLIENT.
        client = serverSocket.Accept();

CLIENT

        client = new Socket();
        InetSocketAddress socketAddress = new InetSocketAddress(address, port); <<< PORT PASSED FROM THE SERVER
        client.Connect(socketAddress);

Is there any way I can pass additional information to the peer that it can use for connection, such as the port number?

Thanks

-John

JohnKoz
  • 908
  • 11
  • 21
  • You could check the link below about how to transfer the value from client to server. https://stackoverflow.com/questions/41053544/peer-to-peer-data-sharing-using-wi-fi-direct/41063269#41063269 – Wendy Zang - MSFT Jul 27 '20 at 09:20
  • Thanks @WendyZang-MSFT, but this example assumes a connection is established first. The above post is asking to pass the port number BEFORE the socket is connected, because the port number is required to make the connection. – JohnKoz Jul 27 '20 at 23:05

0 Answers0