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 >> and << 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?

1 Answer 1


CNode has a method SocketSendData() which pushes all the serialized data into the socket.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.