I am testing a chat bot and want to gracefully handle for times when the chat server isn't running so it can come back up when the service is available again. I have the programming handled. My question is how to test this when the downtimes are not reliable. Someone suggested "Terminate the socket connection manually". How would I do this?

This is a console node.js running on Mountain Lion. Can I sever a connection to a server from a single application?

  • How about details of the implementation? C/Java/Python? OS? And maybe a clarification from the person making the suggestion as to what they meant.
    – Karlson
    Sep 17, 2012 at 14:22
  • The tags said it all, but I added it to the question anyway.
    – Mike Wills
    Sep 17, 2012 at 14:25

1 Answer 1


For closing an in-progress connection, you can forge a TCP RST packet. The tcpkill utility included in dsniff can do this. According to the dsniff FAQ, "a MacOS X port is available via MacPorts". You could also run this from another computer on the same unfiltered Ethernet segment, or from a dedicated firewall, etc.

To prevent a connection from being created in the first place, firewall rules are your best bet, either on your local machine or again on some dedicated firewall.

For an even simpler solution: just unplug your network cable.

  • Well, ya unplugging works. But then I don't have a connection for other stuff.
    – Mike Wills
    Sep 17, 2012 at 16:01
  • Then use the other real solutions that I listed first.
    – Jim Paris
    Sep 17, 2012 at 16:06

You must log in to answer this question.

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