This is technically very difficult, and in some cases will be more error prone than actually providing the service!
You could probably get away with accepting the connection for unknown ports, blackholing the data, then closing the connection after a timeout.