How to block a port

Hi,
i faced a problem, where i have to block a port, therefore nobody used it, evenwith SO_REUSEADDR flag. How can i achive it.

Without knowing any more - consider using a firewall.

If a port is "busy" you cannot bump the user off the port unless you kill the process that has the socket to the port open. Then you open the port and block it.

It sounds like you want some kind of firewall rather than a simple C program.

i think so too, thread moved to ip networking...

Actually our our product facing similar type of problem. Therefore, i need it. Anybody will help me.

Well, the simplest way to achieve something like this (for *nix) is to link your app with libwrap: libwrap - Wikipedia, the free encyclopedia and then bundle tcpwrappers + a sample hosts.allow and hosts.deny with your product.

I'm sure windows has similar api functionality for their packet filter.

Alternatively you can come up with an internal packet filter for the application based on a configuration file, parser and logic that you devise.
It's very simple in theory...An ip based ruleset is created via flat file, xml, etc.., then on a client connect the ruleset is parsed, the client address is
compared for exclusion. If exclusion is indicated the connection is closed with no further processing except, perhaps, for a log notice, otherwise the client
is serviced.