• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Client Server File transfer

 
Adrian Lee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone. I'm building a client-server file transfer project. I was told to use DataOutputStream and DataInputStream.


I've some codes that I've found from a Java cookbook which is able to open a connection port to send a message to the server. I've managed to get the client and server to communicate.

However, I'm kinda lost on how can I get it to transfer a file. Can any kind soul guide me on how I can acheive that?

Many thanks~!!
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it's as easy as read bytes from disk on one end, send bytes over the wire, write bytes to disk on the other end. You can make up a protocol, say send a header first with the filename and length, followed by length number of bytes. The Sun Networking Tutorial has some neat examples of the "knock knock" protocol that should be good inspiration.
 
Adrian Lee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks James. Will look into that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic