JustMeGaaRa
JustMeGaaRa

Reputation: 520

How can I make two apps find and connect via LAN?

I need to scan the LAN for similar app running and then establish connection between them so I can exchange some commands between them. I code in C#. The only way I've found so far is to generate IP's and ping them... but it'd take too many time. Is there a quicker way? Maybe it can be done via WIN_API and then wrapped by C# [DllImport("..")] extern methods?

Upvotes: 1

Views: 731

Answers (2)

McKenzieG1
McKenzieG1

Reputation: 14189

This gets a lot easier if you add a "rendezvous" or "discovery" server. It can be very simple - add/remove "active client" IPs and query for list of clients are the essential functions. If you have a central database the clients can access directly you don't need any "server" code at all - just an "active clients" table.

Upvotes: 0

Steven Doggart
Steven Doggart

Reputation: 43743

You could use UDP to broadcast your presence so that other applications could hear you and establish a socket with you for further communication.

Upvotes: 5

Related Questions