views:

279

answers:

4

Is it possible to emulate incoming messages using Indy (if it's of any importance: I'm using Indy 10 and Delphi 2009)? I want to be able to create these messages locally and I want Indy to believe that they come from specific clients in the network. All the internal Indy handling (choice of the thread in which the message is received and stuff like that) should be exactly the same as if the message would have arrived over the network.

Any ideas on that? Thanks in advance for any tips.

A: 

Indy doesn't have any built-in mechanisms for this but thinking off the top of my head I would recommend building a small test application (or a suite) that runs locally on your development machine and connects to your Indy server application to replay messages.

It should be irrelevant to your Indy server applications if a TCP connection is made either locally or from a remote host as the mechanisms by which a server thread is created and a command processed is identical to both scenarios.

My last gig involved using Indy and all our testing was done with a similar Resender type application that would load local message files and send these to the Indy server app.

HTH and good luck!

Nazar
BUT: Indy will then get the IP adress and port number of the locally running application and the processing of the incoming message is running in an extra listener thread created for that connection. It doesn't have the same effect as another client sending the message. But thanks for the answer anyway!
Smasher
I find your comment abit confusing as Indy creates a new listener thread for any incoming connection, be it local or remote. I am assuming you are using TIDTCPServer and have defined your command handlers. TidTCPServer creates a new thread of any new connection made and process the command handlers in the context of that newly created thread.
Nazar
Exactly! And I want a command executed in a client specific listener thread without having the client to send a message. Understand?
Smasher
Ahh!! Penny drops! Sorry... coffee not kicked in yet!
Nazar
+5  A: 

What you want to do has nothing to do with Indy, as you would need to do this on a much lower level. The easiest way to make Indy believe that messages come from a specific client is to inject properly prepared packets into the network stack. Read up on TCP Packet Injection on Google or Wikipedia. EtterCap is one such tool that allows to inject packets into established connections. However, this is definitely going into gray areas, as some of the tools are illegal in some countries.

Anyway, all of this is IMHO much too complicated. I don't know what exactly you want to do, but a specially prepared client or server is a much better tool to emulate certain behaviour while developing server or client applications. You can run them locally, or if you need to have different IP addresses or subnets you can do a lot with virtual machines.

mghie
+1 as usual, great answer! Bad news for me though :(
Smasher
A: 

One thing you can do would be to create virtual machines to run your test clients, that way they will not be seen as "local machine", and its fairly simple to create a complex network with VMS -- provided you have enough memory and disk space. The other advantage of testing with VM's is you can eliminate the development environment completely when its time to focus on deployment. Amazing how much time that saves alone.

VirtualPC is a free download from Microsoft and works fairly well. VMWare has another option, but costs a little more to get started. For development purposes, I prefer the desktop versions but the server versions also work well. You will still need to have a license to install the virtual OS. MSDN membership is probably the cheapest way to go, and allows you to build test environments for other flavors of the OS.

skamradt
VMWare Server is free, also is VMWare ESXi, and Sun's VirtualBox
mjustin
A: 

Indy has abstract stack mechanism for crossplatform support (IDStack.pas) I think u can hack the stack for windows (IdStackWindows.pas). It is a class. U can even consider to derivate it and override some functions to do the hack.

AhmetC