开发者

close a socket from shell

开发者 https://www.devze.com 2023-04-11 07:10 出处:网络
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, w

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

精彩评论

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