On windows: look at WSAAccept, may be it is what you need:
SOCKET WSAAccept(
__in SOCKET s,
__out struct sockaddr *addr,
__inout LPINT addrlen,
__in LPCONDITIONPROC lpfnCondition,
__in DWORD dwCallbackData
);
lpfnCondition -- the address of an optional, application-specified condition function that will make an accept/reject decision based on the caller information passed in as parameters, and optionally create or join a socket group by assigning an appropriate value to the result parameter g of this function. If this parameter is NULL, then no condition function is called.
For linux solution look at: GNU Common C++ -- TCPSocket class, it has onAccept(), and reject() methods.
virtual bool TCPSocket::onAccept ( const InetHostAddress & ia,
tpport_t port
) [inline, protected, virtual]
A method to call in a derived TCPSocket class that is acting as a server when a connection request is being accepted.
The server can implement protocol specific rules to exclude the remote socket from being accepted by returning false. The Peek method can also be used for this purpose.
However, you can just close socket after accept if pre-condition is false :)