Literadix
Literadix

Reputation: 1407

TCP/IP server mock/stub software needed

I am looking for a software to mock a tcp/ip server. What I need is an easy to use tool (might cost something) which I can use to act as a server and where I can define a protocol flow with some constrains, for example executing the following flow:

  1. Server starts and listens on a tcp/ip port
  2. When a client connects, it send a welcome message
  3. It expects a response message from the client.
  4. The it send a second message etc etc

Is there someone who can give me a hint? I am looking for ready to use software, not a library etc. It might be for Linux or Windows systems.

Thank you very much,

Maciej

Upvotes: 2

Views: 3372

Answers (1)

jsalvata
jsalvata

Reputation: 2205

A simple solution is to use expect and tcpserver. The later comes with the ucspi-tcp package in Ubuntu and hopefully other debians.

Example:

Run this on one console:

$ tcpserver localhost 3333 expect -c 'expect "hello" ; send "hi\n" ; expect "bye" ; send "see you\n"'

And this on another:

$ telnet localhost 3333
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
hello
hi
bye 
see you
Connection closed by foreign host.

Upvotes: 7

Related Questions