How to reject a connection attempt in c#?

前端 未结 2 1281
旧巷少年郎
旧巷少年郎 2020-12-11 22:11

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         


        
2条回答
  •  再見小時候
    2020-12-11 22:21

    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).

提交回复
热议问题