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.