Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to send a file between two computers?

how to send a file between two computers?

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminjsontutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SAK
    wrote on last edited by
    #1

    Guys, Is there an api that sends a file over the network between two computers using their computer names. Can someone give me guidance on how to do this. Regards, SAK

    R 1 Reply Last reply
    0
    • S SAK

      Guys, Is there an api that sends a file over the network between two computers using their computer names. Can someone give me guidance on how to do this. Regards, SAK

      R Offline
      R Offline
      Richard Jones
      wrote on last edited by
      #2

      In C++, you would use CSocket class or a derivative. One application would be the server, and listen for client(s) to connect on a given port. The other app would be the client(s) and try to connect to a server by name and port. Hint: if you are testing on 1 pc, hostname of "loopback" is valid. Once a connection has been established, the client opens and Sends the file, and the server's Receive handles the incoming data packets, writing them to a file. I suggest reading the online help on sockets. There are also user-written wrapper classes for sockets you could examine.

      S 1 Reply Last reply
      0
      • R Richard Jones

        In C++, you would use CSocket class or a derivative. One application would be the server, and listen for client(s) to connect on a given port. The other app would be the client(s) and try to connect to a server by name and port. Hint: if you are testing on 1 pc, hostname of "loopback" is valid. Once a connection has been established, the client opens and Sends the file, and the server's Receive handles the incoming data packets, writing them to a file. I suggest reading the online help on sockets. There are also user-written wrapper classes for sockets you could examine.

        S Offline
        S Offline
        SAK
        wrote on last edited by
        #3

        Rick, Thank you for the help, I was pretty sure I needed to use sockets (something I am not familiar with) but was hoping there was an API for this. Anyways, I am going see if I can learn how to use sockets. Thanks again for the response.

        V 2 Replies Last reply
        0
        • S SAK

          Rick, Thank you for the help, I was pretty sure I needed to use sockets (something I am not familiar with) but was hoping there was an API for this. Anyways, I am going see if I can learn how to use sockets. Thanks again for the response.

          V Offline
          V Offline
          Vladimir Georgiev
          wrote on last edited by
          #4

          There is an API that uses the Windows File Manager (or how they call it) that can copy files or directories to a remote computer over the network, if it has a shared directory with full rights. E.g. it will copy the file to \\Destination_Comp\Directory\. If you are interested, I can tell you how it works. "Needless redundancy is the hobgoblin of software engineering." - Peter Darnell

          1 Reply Last reply
          0
          • S SAK

            Rick, Thank you for the help, I was pretty sure I needed to use sockets (something I am not familiar with) but was hoping there was an API for this. Anyways, I am going see if I can learn how to use sockets. Thanks again for the response.

            V Offline
            V Offline
            Vladimir Georgiev
            wrote on last edited by
            #5

            TCHAR pszFrom[1024] = {0}; TCHAR pszTo[1024] = {0}; SHFILEOPSTRUCT shfo; GetDlgItemText( IDC_SOURCE, pszFrom, 1024); GetDlgItemText( IDC_DEST, pszTo, 1024); ZeroMemory(&shfo, sizeof(SHFILEOPSTRUCT)); shfo.hwnd = AfxGetApp()->m_pMainWnd->m_hWnd; shfo.wFunc = FO_COPY; shfo.pFrom = pszFrom; shfo.pTo = pszTo; shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT; SHFileOperation(&shfo); This is how it works for me :) you can see more detailed info about SHFILEOPSTRUCT in the MSDN online reference... If any questions, do not hesitate to ask... "Needless redundancy is the hobgoblin of software engineering." - Peter Darnell

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups