2012-07-19 68 views
-1

您好,我將構建兩個測試應用程序,一個在用戶計算機上運行。這將是一個系統托盤類的後臺應用程序來管理指定文件夾的內容。另一個是Admin類型的屏幕,用於顯示當前網絡中的計算機正在運行第一個應用程序並讀取一些數據(文件夾的內容)。應用程序之間的網絡通信

如何通過網絡傳輸數據以查看來自我的應用的特定數據?再次,我只想看看哪些應用正在運行以及它們發送了什麼數據(從Admin屏幕)。

+0

老實說,我希望更多的細節,我不知道是否有良好的術語來什麼,我試圖完成。我應該改述一下這個問題還是什麼? – ikathegreat 2012-07-19 00:45:02

+1

你是否試圖做你所描述的?你有代碼證明特定的失敗?如果您只是想通過網絡進行通信,請嘗試設置一個作爲Windows服務運行的WCF服務,並從管理員屏幕上讀取over net.tcp。 – zimdanen 2012-07-19 00:47:33

+0

是的,我已經準備好了骨架。但我不知道如何將這些數據從一個應用程序發送到另一個應用程序。我一直在尋找,我有VS 2010表達,我沒有可用的WCF模板? – ikathegreat 2012-07-19 01:02:11

回答

0

這種互動通信非常適合ØMQ這是一個帶有套接字API並且不需要代理的異步消息庫 - 有很好的C# Binding

代碼示例:

var publisher = new ZmqPublishSocket { 
    Identity = Guid.NewGuid().ToByteArray(), 
    RecoverySeconds = 10 
}; 

publisher.Bind(address: "tcp://127.0.0.1:9292"); 

// Add a subscriber. 
var subscriber = new ZmqSubscribeSocket(); 

subscriber.Connect(address: "tcp://127.0.0.1:9292"); 
subscriber.Subscribe(prefix: ""); // subscribe to all messages 

// Add a handler to the subscriber's OnReceive event 
subscriber.OnReceive +=() => { 
    String message; 
    subscriber.Receive(out message, nonblocking: true); 

    Console.WriteLine(message); 
}; 

// Publish a message to all subscribers. 

publisher.Send("Hello world!"); 
相關問題