2010-10-23 55 views
0

嘿所有我想從虛擬機(VMWARE)發送文本消息到我的本地機器,以便我可以擊中虛擬機中的按鈕,並讓它做一些事情本地的。幫助您發送文本您的TCP/IP或局域網

是否有無論如何通過IP,TCP/IP,局域網使用VB6或VB.net發送文本?我正在尋找net send發送一些東西,但它似乎不適用於我(以及它似乎彈出一個對話框中發送的每個文本)。我已經嘗試了這一點:

http://www.codeproject.com/KB/vb/CfSimpleSendComp.aspx

但它似乎並沒有在我的電腦在所有的工作?我已經嘗試了機器的IP以及計算機的名稱。也許.NET Remoting在VB中?

任何人都可以讓我知道,如果有其他方法可以做我想做的事嗎?

謝謝!

大衛

回答

1

您也可以考慮使用Eneter Messaging Framework。
它重量輕,使用非常簡單。

我很抱歉,我不熟悉VB語法,但在C#中的整個實現 是在這裏:(你可以複製粘貼代碼到你的項目,包括Eneter.Messaging.Framework.dll和更改IP給你)。

服務器偵聽字符串消息。

using System; 
using Eneter.Messaging.EndPoints.StringMessages; 
using Eneter.Messaging.MessagingSystems.MessagingSystemBase; 
using Eneter.Messaging.MessagingSystems.TcpMessagingSystem; 

namespace StringReceiver 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      // Create Tcp based messaging. 
      IMessagingSystemFactory aTcpMessaging = new TcpMessagingSystemFactory(); 
      IInputChannel anInputChannel = aTcpMessaging.CreateInputChannel("127.0.0.1:7091"); 

      // Create string message receiver 
      // Note: it is possible to receiver typed messages too. 
      IStringMessagesFactory aStringMessagesFactory = new StringMessagesFactory(); 
      IStringMessageReceiver aStringMessageReceiver = aStringMessagesFactory.CreateStringMessageReceiver(); 
      aStringMessageReceiver.MessageReceived += StringMessageReceived; 

      // Attach the input channel to the string message receiver 
      // and start listening. 
      Console.WriteLine("String sercer is listening."); 
      aStringMessageReceiver.AttachInputChannel(anInputChannel); 
     } 

     // Processing messages. 
     static void StringMessageReceived(object sender, StringMessageEventArgs e) 
     { 
      Console.WriteLine("Received message: " + e.Message); 
     } 
    } 
} 

客戶端發送的字符串消息:

using Eneter.Messaging.EndPoints.StringMessages; 
using Eneter.Messaging.MessagingSystems.MessagingSystemBase; 
using Eneter.Messaging.MessagingSystems.TcpMessagingSystem; 

namespace StringMessageSender 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      // Create Tcp based messaging. 
      IMessagingSystemFactory aTcpMessaging = new TcpMessagingSystemFactory(); 
      IOutputChannel anOutputChannel = aTcpMessaging.CreateOutputChannel("127.0.0.1:7091"); 

      // Create string message receiver 
      // Note: it is possible to receiver typed messages too. 
      IStringMessagesFactory aStringMessagesFactory = new StringMessagesFactory(); 
      IStringMessageSender aStringMessageSender = aStringMessagesFactory.CreateStringMessageSender(); 

      // Attach the output channel to the string message sender 
      // so that we can send messages via Tcp to desired Ip address. 
      aStringMessageSender.AttachOutputChannel(anOutputChannel); 

      // Send message. 
      aStringMessageSender.SendMessage("Hello world."); 
     } 
    } 

}

Eneter消息框架可以在www.eneter.net下載。

如果你想獲得更多的技術信息:www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html 更多的例子:eneter.blogspot.com

+0

感謝您抽出時間來寫了這一切,,的Ondrej。不過,我只是使用了一些VB.net代碼。 – StealthRT 2010-10-25 15:12:01

1

你在每端需要一個客戶端和服務器,其中之一。這些可以通過TCPIP(TCP或UDP),Microsoft Networking(名爲Pipes,Mailslots)或任何你有的方式進行通信。有些選項取決於兩臺機器運行的操作系統,但是由於您提到NET SEND,我們可能會假設Windows有一些風格。

信使服務在Windows NT(Vista,Windows 7)的更高版本中消失,所以它不是最好的選擇。還有其他Mailslots使者,以及大量的UDP使者。

真正的問題是你想要執行什麼操作,「按下按鈕」。哎呀,你可以很容易地運行Telnet,如果這給了你以後的東西。

不要忘了你可能必須打開防火牆才能工作。

.Net Remoting在VB中不可用,您的意思是VB.Net。這是一個遠程對象調用技術,但可能不是你想要的。

你可能會更快地得到一個結果,選擇一個開發工具集並使用它提供的任何TCP或UDP套接字。

1

有幾種方法。最好的方法取決於你如何定義'短信'。

如果你真的只需要點擊一個按鈕並在遠程機器上運行命令,我就可以在Process對象中運行PsExec。俗氣但有效。喜歡的東西:

Using p as new Process() 
    p.StartInfo.FileName = "c:\path\to\PsExec.exe" 
    p.StartInfo.Arguments = "\\RemoteComputerName RemoteCommand.exe" 
    p.Start() 
End Using 

如果您需要自定義協議的雙向溝通​​,我會用WCFTCPListener and TCPClient類來創建你自己的套接字服務器和客戶端。

我會遠離遠程處理。

相關問題