views:

40

answers:

3

Hey all i am trying to send a text message from a virtual machine (VMWARE) to my local machine so that i can hit a button in the VM and have it do something on the local.

Is there anyway to send a text through an IP, TCP/IP, LAN using VB6 or VB.net? I was looking at the net send to send something but it doesn't seem to work for me (as well as it seems to pop up a dialog box for every text you send). I've already tried this out:

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

But it doesn't seem to work at all on my computer? I've tried both the IP of the machine and also the computer's name. Maybe .NET Remoting in VB?

Could anyone let me know if there are other ways to do what i would like to do?

Thanks!

David

+1  A: 

You need a client and a server, one of them at each end. These could communicate over TCPIP (TCP or UDP), Microsoft Networking (named Pipes, Mailslots), or whatever you have. Some options depend on what OS the two machines are running, but since you mentioned NET SEND we can probably assume some flavor of Windows.

The Messenger Service is gone in later versions of Windows NT (Vista, Windows 7) so it's not the best option. There are other Mailslots messengers though as well as lots of UDP messengers.

The real question is what action you want to perform "at the push of a button." Heck, you could easily run Telnet if that gave you what you were after.

Don't forget you may have to open firewalls for any of these to work though.

.Net Remoting isn't available in VB, you must mean VB.Net. That's a remote object invokation technology though and probably not what you want.

You'd probably get to a result more quickly picking one development tool set and using whatever it offers for TCP or UDP sockets.

Bob Riemersma
+1  A: 

There are several ways. The best way depends on how you define 'text message'.

If you literally just need to hit a button and run a command on a remote machine, I would run PsExec in Process object. Cheesy but effective. Something like:

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

If you need bi-directional communication with a custom protocol, I would use WCF or the TCPListener and TCPClient classes to create your own socket server and client.

I would stay away from remoting.

nFreeze
+1  A: 

You also can consider to use Eneter Messaging Framework.
It is lightweight and very easy to use.

I am sorry, I am not familiar with VB syntax, but in C# the whole implementation is here: (You can copy paste the code into your project, include Eneter.Messaging.Framework.dll and change the IP to yours.)

The server listening to string messages.

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);
        }
    }
}

The client sending the string messages:

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 Messaging Framework can be downloaded at www.eneter.net.

If you would like to get more technical info: www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html More examples: eneter.blogspot.com

Ondrej Uzovic
Thanks for taking the time to write all that out, Ondrej. However, i just used some VB.net code.
StealthRT