0

I want to create a page that simulates a hung/frozen web page. For example, I could use a really long "sleep" in PHP. But if I wanted to make this a public tool, I could well imagine this might eat up server resource (sockets, memory, etc - I'm not that experienced at this level of abstraction) and eventually cause real problems for the server.

I don't want to simply close the socket with the client, because that would not provide the type of "waiting" behavior I want to simulate.

The solution doesn't have to be PHP related. That was just an example. It can be any language and/or web server. The only criteria is FOSS on Linux.

DG.
  • 3,417
  • 2
  • 23
  • 28
  • For anyone interested, I stumbled upon a somewhat related question elsewhere: http://stackoverflow.com/questions/100841/artificially-create-a-connection-timeout-error – DG. Mar 30 '16 at 06:21

1 Answers1

1

You can simply use netcat to listen on a port and return nothing.

nc -l localhost 8080

Or if you wanted it to continue listening when the client has closed the connection

while (TRUE); do nc -l localhost 8080; done

edit: some versions of nc have the -k option to force netcat to continue listening after the socket is closed. In those cases you don't need to loop.

Eric
  • 2,056
  • 13
  • 11
  • What happens if a 2nd client tries to connect to the same port before the 1st client has closed the socket? – DG. Jun 11 '14 at 13:48