3

Regarding the question Simple command line HTTP server I would like to know, what is the simplest method for creating a http server listening on a specified port that will always cause timeout (it just eats the request and never responds).

I am looking for a dead simple oneliner. It would be useful for the purpose of testing clients.

mirelon
  • 143

2 Answers2

4

You can use NetCat to just listen on a port and do nothing:

nc -l $PORT
tantalum
  • 154
2

If it doesn't have to respond, you can use netcat.

nc -lp [port] -w [timeout]

Option -l to use netcat as server, -p for the port and -w for the timeout.

ulmer-a
  • 219
  • -w [timeout] closes the socket, producing a broken pipe exception in the client (e.g. Excon::Errors::SocketError: Broken pipe - Broken pipe (Errno::EPIPE)). It was not exacly my usecase, but it can help someone. – mirelon Feb 16 '15 at 17:02