-2

I'm working on a very important school project in c# windows forms. It will be about a system separated in 2 parts. I have 2 apps and they should be on 2 different PCs. The first app called A should be on PC1 and the second app called B should be on PC2.

They will be connected via the same LAN. The only function of app 1 is to activate a window log in app 2. Well, I'm still a rookie in C# and I don't know what kind of connection to use or how to connect them.

Mouse On Mars
  • 1,076
  • 9
  • 25
Overpool
  • 1
  • 1
  • What have you tried? Please show us some code so we can helop – Mouse On Mars Mar 20 '19 at 19:11
  • There are too many ways to approach this problem. The answers would just turn into a straw-poll for which one people liked. The best thing is to do some research on the topic yourself, find two or three, _analyze_ them, determine if they work for you or not, and _try them out_. Come to us when you have a specific question about something you have attempted to do. – Patrick Artner Mar 20 '19 at 19:22
  • See f.e. [what-is-the-simplest-method-of-inter-process-communication-between-2-c-sharp-pro](https://stackoverflow.com/questions/528652/what-is-the-simplest-method-of-inter-process-communication-between-2-c-sharp-pro) – Patrick Artner Mar 20 '19 at 19:23

1 Answers1

0

If connection is safety critical in your app you need to use TCP/IP, if is not just use UDP Socket connection. It recommended for short messages.

UDP connects other LAN PC with it's IP and PORT number and also your server PC (A or B) need to listen it's port. Example for Client Side:

            Client = new TcpClient("192.168.1.1", "1111");
            Stream = Client.GetStream();
            Stream.Flush();
            data_inc = new Byte[256];

            data_inc = System.Text.Encoding.ASCII.GetBytes("Your MESSAGE" + "\n");

            Stream.Write(data_inc, 0, data_inc.Length);
            Array.Clear(data_inc, 0, data_inc.Length);

            // Read the first batch of the TcpServer response bytes.
            bytes = Stream.Read(data, 0, data.Length);

            //if you recieve any response 
            responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);