Gibsondude
Gibsondude

Reputation: 61

Send a string from Console Application to WindowsForm application

I have created an Android application which sends a string over wifi to a console server on my computer. Basically, when a user touches the button on the Android application, the app sends a "connect" string to the server, pressed again and it sends a "disconnect" string. Once the string is received I need to pass it from the console server to a windows form running on the same machine. This is where I'm stuck, how do I send a string from the server to the windowsform application? I'm using C# btw... Thanks

Upvotes: 0

Views: 718

Answers (5)

Awtszs
Awtszs

Reputation: 341

You may use this class NamedPipeServerStream

[HostProtectionAttribute(SecurityAction.LinkDemand, MayLeakOnAbort = true)]
 public sealed class NamedPipeServerStream : PipeStream

Upvotes: 1

Patrick Hofman
Patrick Hofman

Reputation: 156968

Another possibility is to use named pipe streams, which also works over internal networks. For communication between two applications, you could use what you seem best. Read this documentation on MSDN on named pipe streams.

Upvotes: 0

Dirk
Dirk

Reputation: 10958

There are various way to achieve that. The technical term for what you want to do is Interprocess Communication (IPC) and there are many different ways to do that.

Since you are using .NET on both client and server your task is significantly easier: you can use the Windows Communication Foundation. WCF allows you to easily create a client/service that communicate over various channels, incuding TCP/IP and Named Pipes.

You can find a Small Sample Project WCF service on CodeProject.


Other methods would be sockets (TCP or even UDP), named and anonymous pipes, files on shared network folders, shared memory or message queues.

Upvotes: 0

PhillyNJ
PhillyNJ

Reputation: 3903

As T McKeown suggested, you can create a Socket Listener

The link provides a complete example (Client and Server). In your case the client will be android, which will be different.

Upvotes: 0

T McKeown
T McKeown

Reputation: 12847

You need to "communicate" with it ;). Use WCF or create your own TCP/IP socket client/server app between the 2 .net apps.

Upvotes: 0

Related Questions