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:
- Server starts and listens on a tcp/ip port
- When a client connects, it send a welcome message
- It expects a response message from the client.
- 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 Lin开发者_如何学Goux or Windows systems.
Thank you very much,
Maciej
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.
精彩评论