how to send a file between two computers?
-
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
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.
-
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.
-
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.
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
-
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.
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