简体   繁体   English

使用Java套接字编程进行文件传输查询

[英]query on file transfer using java socket programming

I need to move few files in a directory to another directroy in another machine . 我需要将目录中的几个文件移动到另一台计算机上的另一个目录。 The source and destination directory names are known in advance. 源和目标目录名称是事先已知的。 These directories will be in different Operating System (ie the source can be Linux and Destination can be in Windows). 这些目录将位于不同的操作系统中 (即,源可以是Linux,目标可以在Windows中)。

To solve this, i wrote a Socket program in Java that successfully copies files from source directory to a destination directory(Tested in Windows OS). 为了解决这个问题,我用Java编写了一个Socket程序,该程序成功将文件从源目录复制到目标目录(在Windows OS中经过测试)。 But this application needs program running in both the host and remote machine. 但是此应用程序需要在主机和远程计算机上都运行的程序。 So, my question is : 所以,我的问题是:

1) Is there any way to transfer files(in the ways described above) using Java Socket program without having a program running in the remote machine? 1)是否有任何方法可以使用Java Socket程序传输文件(以上述方式),而无需在远程计算机上运行程序?

2) Whether file transfer using Java socket program, bypass firewal. 2)是否使用Java套接字程序传输文件,请绕过firewal。 In other words, if a firewall is present in the remote machine will that stop the transfer process? 换句话说,如果远程计算机中存在防火墙,那将停止传输过程吗?

3) Any alternative approach to transfer files(in the ways described above) using Java where only the host or remote need to run.? 3)在仅需要运行主机或远程的情况下,使用Java传输文件的任何其他方法(以上述方式)。

Thanks in advance, nks 预先感谢,nks

1) You always need a program running on both machines. 1)您总是需要在两台计算机上都运行一个程序。 However, a way to get around this problem is to use a program already running on one of these machines. 但是,解决此问题的一种方法是使用已经在其中一台计算机上运行的程序。

eg If you make the directory a Windows share (assuming this is already running) you can mount this share on the Linux box (using smbfs), you can then copy files using cp This means you don't need Java on either end, but you need A program and A service (but it can be an existing one) 例如,如果将目录设置为Windows共享(假设此目录已在运行),则可以将该共享安装在Linux机器上(使用smbfs),然后可以使用cp复制文件。这意味着您两端都不需要Java,但是您需要一个程序和一个服务(但它可以是现有的)

2) There isn't a way to by-pass a firewall unless your network is seriously mis-configured. 2)除非您的网络配置严重错误,否则无法绕过防火墙。 This is the whole point of having one. 这就是拥有一个的重点。

3) Once you mount either the Windows box on Linux, or the Linux files (using Samba) on Windows youc an copy files easily, even using Java. 3)一旦在Linux上安装Windows框或在Windows上安装Linux文件(使用Samba),就可以轻松复制文件,甚至使用Java也可以。 ;) ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM