开发者

close a socket from shell

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 th开发者_JAVA技巧e client & server are in the middle of some exchange. Is this doable though a shell command ?


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.


No, not on standard linux, there is no such facility.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜