How does CDataStream data find its way into a socket? I am curious to know how and where in the source code, the data from stream is actually sent by a node. As per my understanding the following occurs:


ProcessMessage() issues a PushMessage() with appropriate parameters
PushMessage() will basically send message headers and parameters into a stream ssData
ssData is object of CDataStream and defined in CNode
CDataStream is in src/stream.h has no information related to IP or Port


How does the data being pushed to a stream goes into the correct socket in bitcoin working. Only CNode class has information on the network address (IP) and TCP Port. How is this information picked up by the datastream? 

Adding more findings:

I found this from https://bitcointalk.org/index.php?topic=41727.0

The socket thread reads the sockets and places data into a CDataStream
associated with each node called vRecv. The Satoshi client uses C++
serialization operators &gt;&gt; and &lt;&lt; to read and write to a CDataStream
and then it uses generic routines to move the data between the streams
and sockets


My exact question is where(what) are these mentioned generic routines in source code?
CNode has a method SocketSendData() which pushes all the serialized data into the socket.

https://github.com/bitcoin/bitcoin/search?utf8=%E2%9C%93&amp;q=SocketSendData&amp;type=Code