2

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

1 Answer 1

7

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.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.