• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File trasfer between machines

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello

i need java program to transfer files between two machine.

As a first step i get the list of files in the machine(source).
i create a socket class object like this



it gives following excetion.

java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect

what is the error in Socket class . please help me.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The other PC should have a server socket listening on that same port, or of course it will fail.

Why not use a known protocol like SMB (also known as Windows sharing, Samba is the Unix / Linux implementation) or FTP?
 
joseph prabhu
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rob Prime:
The other PC should have a server socket listening on that same port, or of course it will fail.

Why not use a known protocol like SMB (also known as Windows sharing, Samba is the Unix / Linux implementation) or FTP?



hello

i create the ServerSocket class object of constructor


it gives the exception called

java.net.BindException: Cannot assign requested address: JVM_Bind
java.net.BindException: Cannot assign requested address: JVM_Bind

but it does not give the exception for other 2 constructors
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The third parameter to the ServerSocket constructor should be the IP address or hostname of the server itself, in case you have multiple IP addresses or hostnames. In your case you probably won't need that so you can just omit it.

That parameter does NOT indicate the client - servers shouldn't care about who their clients are*, as long as they follow the protocol.


And don't forget to start the server before starting the client


* Of course it's possible to block IP addresses because of security, but that's at a higher level.
 
joseph prabhu
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rob Prime:
The third parameter to the ServerSocket constructor should be the IP address or hostname of the server itself, in case you have multiple IP addresses or hostnames. In your case you probably won't need that so you can just omit it.

That parameter does NOT indicate the client - servers shouldn't care about who their clients are*, as long as they follow the protocol.


And don't forget to start the server before starting the client


* Of course it's possible to block IP addresses because of security, but that's at a higher level.



i am going to develop the one program to copy the files between the machines

not as client or server program. is it correct.
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you started using Sockets, so you need some server (ServerSocket) to connect to. That makes this a client-server solution.

Like I asked before,

Originally posted by Rob Prime:
Why not use a known protocol like SMB (also known as Windows sharing, Samba is the Unix / Linux implementation) or FTP?


You can then use the java.io package. You will need a third party library for the FTP part, but Apache Commons Net and JvFTP are great for that.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic