Click here to Skip to main content
15,885,278 members
Articles / Desktop Programming / MFC

Peer-to-Peer Communicator and File Transfer

Rate me:
Please Sign up or sign in to vote.
4.33/5 (57 votes)
14 Aug 20013 min read 390.3K   21.9K   167  
Get youself a peer-to-peer communicator and exchange files across a network.
* CFileInfo is a node in a hierarchy of files of a local file system. 

* CNetFileHdr class takes a pointer to CFileInfo.
  It calculates and saves the number of packet to be sent.
  It saves the local path as well .
  It can tell whether this is a file or a directory
  It can tell the total size of the file.
  It can ask the CNetPacket of its size.

* Okay now I have an OS file tree built and I can generate
  a net header class (CNetFileHdr) for a file/directory represented by CFileInfo.

? What do I do with a recursive copy? What if a directory is selected for copy?

* There has got to be a send/receive controller then. It will have a pointer
  to a root node (CFileInfo) and will send/receieve all subfiles/subdirectories
  from there. Let's call it CSendReceiveController. CSendReceiveController will have
    - AttachProviderStream();
    - AttachConsumerStream();

  Sending	: Set a pointer to a root CFileInfo in CSendReceiveController.
              CSendReceiveController will iterate through all subitems of CFileInfo.
			  For each CFileInfo create a CNetFileHdr and pass a pointer to CFileInfo into it.
			  Create a CNetFile and pass a pointer to CNetFileHdr into it.
			  Call CNetFile::SendReceive(CSendReceiveController::GetProviderStream(), CSendReceiveController::GetConsumerStream()), which
			  will receive a CNetPacket at a time from ProviderStream and send this packet to the Consumer stream
  Receiving : 

CNetFile class take CNetFileInfo with local/remote file info
CNetFile attaches to ProviderStream()
CNetFile attaches to ConsumerStream()
CNetFile
NetStream >> NetFileInfo

NetFile
NetFile

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here



Comments and Discussions