Can Java Block Open TCP ports?
E.g i am trying to build a software which can block TCP ports开发者_开发技巧 by my choice which are being used by applications. Is there any means to accomplish such?
The only way to "block" a TCP port for a Java program is to open its own server on the like, so no other software can use this port anymore.
If you want to implement a firewall, you have to use the specialised APIs of your operating system, like ipchains on linux, or the corresponsing windows API. This API is also used by the windows firewall and all other firewalls on windows.
This however needs native code, so have a look at JNA or JNI.
精彩评论