views:

510

answers:

3

Lets say I have my C# app installed on 2 laptops connected to a WiFi Wireless Local Area Network.

How can these apps send messages to each other? What method or library can I use? I heard of using sockets but I have no idea how to work with these.

+1  A: 

Basically, you'll want to do it the same way you would in any other language. You'll open a network connection of one flavor or another (raw TCP or UDP, or a higher level protocol like HTTP) with one side acting as a server and the other acting as a client. Then each side can write data through or read data sent by the other side. It's can get pretty complicated from there. If you Google "C# Sockets" or "C# HTTP", etc, you'll find quite a few tutorials on the subject.

Russell Newquist
+1  A: 

This is a very good article on sending C# objects (which could include whatever messages that you want to send) over a Socket connection using the Binary Formatter. Although it is not the most efficient, it is quite easy to grasp and get working.

kersny
+3  A: 

You could use WCF to build a communication pipe between the 2 applications. WCF encapsulates the sockets into a more manageable interface. You can start here.

Andrew Keith