I have a socket that listens for connections. What I want to do is to have an accept / reject option when a connection is attempted. This is my code:
private
You (almost) always want to Accept the connection, because the decision whether or not to connect can only come based on information sent from the client (user name, password, etc).
So after you establish a connection, run your authorization module to gather the authentication information and based on that, decide whether or not to call Close on client (in your example).