'No CloseRead() / CloseWrite() implementation for tls.Conn
I am currently trying to switch a Go server from using a net.TCPConn to using a tls.Conn for its API calls. The problem I am running into is that my server relies on net.TCPConn's ability to close the read and write connection independently (via net.TCPConn.CloseRead() and net.TCPConn.CloseWrite()), a feature which is not implemented at the net.Conn level or in tls.Conn implementation.*
* I know that tls.Conn does have an implementation of CloseWrite(), but under the hood this method only calls SetWriteDeadline() and doesn't close the file descriptor, which is the functionality that I need.
My questions are as follows:
- Is there a specific design reason for not having an implementation for
CloseRead()andCloseWrite()innet.Conn? It looks like the implementations ofnet.Connthat have these methods define them almost identically. - Why isn't there an implementation of these methods in
tls.Connwhich closes the file descriptors?
Thank you in advance for your response!
Solution 1:[1]
... my server relies on net.TCPConn's ability to close the read and write connection independently ...
Relying on this is usually done to signal to the peer that no more data will be sent while still being able to receive data. This ability is specific to TCP, where one side can send a FIN to signal end of transmission while still receiving data.
Since it is not a generic feature of network connections but specific to TCP it makes no sense to provide an interface for this in the generic net.conn. Similar TLS also does not have the concept of a read-only connectivity after a one-side shutdown - see boost ssl half close socket is possible? for details.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Steffen Ullrich |
