You can't get them from the sockets library. It's job is to stop you worrying about such things.
You will need to packet capture in a seperate thread. The pcap (captured packets) will have all the commiunication info. You need to find the matching TCP packets and inspect them.
I've done this before. It's not as tricky as it sounds.
It's not odd if you understand the networking stack. When using a socket library, you are at the Application layer. TCP header information is in the Transport layer. The point of these layers is to separate out concern to only the relevant parties. As an application developer, you don't care about the transport information - you just care about application data. That is what a socket library will provide for you.