• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Transfer file from a client to server

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wrote a client server program where client send request and reciev reply and the server makes connection for each client and tehn echoes the client request.
I want to modify this program too send a file from client to server.
How can i do that any help will be appreciated.
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi J.N.,
Welcome to JavaRanch!
We ain't got too many rules round these parts, but we do have our naming policy. Your display name can't be an obvious fake, like your'n. Thank you kindly for hot-footin' it over here to fix yours up!
Now, on to your question.
If you've written the echo server you've described, I'm not sure why you'd have a problem with transferring a file. Just open the file and spit all the data through the connection. Of course, the server has to be waiting for it. To make life easier, you might want to send the file name and file size first, and have the server be expecting that, too.
Be sure to use InputStreams and OuputStreams, not Readers and Writers, to transfer the data, or your program won't work for non-textual files.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Robert Martin has been writing a series about sending compile jobs to a server - send source and get back listings and class files. It has some neat ideas about wrapping files in objects for socket transfer. See if somebody has a stack of Software Development magazines, or try http://www.sdmagazine.com/columnists/martin/ online. His ObjectMentor.com site is not responding right now, but if it comes back the articles are there, too.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic