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.

2 Answers 2

4

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

nc -l $PORT
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.

1
  • -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, 2015 at 17:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .