Question: I'm trying to create a custom FTP server with TcpListener over SSL.

When closing the connections the client generates an error because when the socket gets shutdown is not sending `close-notify` alert. Which I have read is not considered in .NET TLS implementation.

What would be the best way to add this behavior to my server. How do I send this alert? Is it simple as writing the string to the SSL stream or wrapped stream.

I would appreciate if someone can point me in the right direction.

Thanks

Answer: 
I found that SslStream just simply does not support this, so the only alternative I see at this moment is to send it manually. It is what I would call "manual sunset".

I posted my code [here](https://stackoverflow.com/questions/237807/net-sslstream-doesnt-close-tsl-connection-properly/22626756#22626756) (since it was the most earliest mentioning of the problem I could find). Please have a look and advise if it helps you.

I hope Microsoft will find time to fix it in next versions of the framework.
`close-notify` should be sent automatically by the SSL layer when you close the socket, if you were the end that closed first. If you were the end that received EOS and so you are closing in response, [RFC 2246](http://www.ietf.org/rfc/rfc2246.txt) allows for `close-notify` not to be sent in response.

You can't send it yourself.