Mario Stoilov
Mario Stoilov

Reputation: 3447

Windows store app: Peer to peer connection

I am having a little trouble with the windows 8 store apps. My question is simple:

I have a windows 8 store app on 1 pc, and the same app on another pc. The PCs are not in the same network, but have internet. I want to send a message (string/bytes) from PC A, to PC B.

How can I do that?

EDIT:

OK, the StremSocket connection works. I successfully sent data from PC A, to PC B. I will write a simple demo to demonstrate it. Now comes the tricky part - the discovery.

My idea is simple: Make an Azure service which holds a database whith the peers in the form (ip,port,timeout). There will be a few rules.

  1. When you make "server", the app will notify the service every 1 second for it's existance.
  2. When the service recieves data from an app in the form (ip, port), it will check if this entry exists in the database:
    2.1 If yes - reset the timeout of the entry to 0
    2.2 If not - insert the server in the database with initial timeout 0
  3. Every second the service will update the database by these rules:
    3.1 Increase the timeout of every entry by 1
    3.2 If an entry has a timeout>5 (has not reconnected for 5 seconds) - remove it.

I'm sure there is a smarter solution, but this one seems like little work, and I think it should work for my needs. What do you guys think?

Upvotes: 2

Views: 1088

Answers (1)

N_A
N_A

Reputation: 19897

I think the StreamSocket is what you want. This will allow connection and back-and-forth communication between two clients. If you want them to be able to find each other you will probably have to provide a service hosted on a server somewhere which will list the available client connections.

Upvotes: 2

Related Questions