title: retrieving TOS value on a TCP socket
body: <p>I have a scenario where a client opens a TCP connection to a server after setting some IP TOS value (<code>setsockopt(.., IP_TOS, ..)</code>. On the server I want to retrieve the received TOS value and set that on the socket so that the received TOS is reflected back on server-client packets.</p>
  
  <p>The problem is, on the server side, how can I retrieve the TOS value received from the client? I can assume that the client will not change the TOS value during the entire session, so it is sufficient to get and set the TOS value once initially.</p>
  
  <p>Setting <code>IP_RECVTOS</code> and using ancillary data works for UDP but not for TCP sockets. How can something similar be achieved on TCP sockets? <code>getsockopt(2)</code> with <code>SO_PRIORITY</code> or <code>IP_TOS</code> returns the configured values on the local socket. So if I did a <code>setsockopt()</code> locally then the <code>getsockopt()</code> reflects that value. It is not reflecting what is received on the network.</p>