Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
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 '12 at 14:22
    
The tags said it all, but I added it to the question anyway. –  Mike Wills Sep 17 '12 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.

share|improve this answer
    
Well, ya unplugging works. But then I don't have a connection for other stuff. –  Mike Wills Sep 17 '12 at 16:01
    
Then use the other real solutions that I listed first. –  Jim Paris Sep 17 '12 at 16:06
    
I'll try that. Thanks! –  Mike Wills Sep 17 '12 at 16:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.