Reputation: 3975
I am working on a feature that relies on socket communication. One test case I am considering is abrupt socket failures. for ex: I want to close the socket the client has established from the shell, when the client & server are in the middle of some exchange. Is this doable though a shell command ?
Upvotes: 0
Views: 1338
Reputation: 283624
Do you want to close it (per your title), or abruptly interrupt it in order to test error-handling code (per your explanation)?
You should be able to interrupt communications on a particular socket using netfilter and appropriate match engines (e.g. pid and port number), and you definitely can run iptables
from the shell.
If you want to close the socket, you can just terminate the peer process.
Upvotes: 2