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

Copying Files over a Socket

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I want to copy files over a network reliably. The program I have works except for two things:
  • The socket connection should terminate after receiving the file. In runtime, the connection does not terminate. My guess is, the client is stuck in the for loop that reads the file from the network.
  • When I used a test file, numbering the lines from 1 to 1000 (each lines reads "[number] ----- L" ), I noticed about 60 extra lines at the end of the file. Probably this is because I read into and copy from 1024-byte arrays which don't totally get written over at the end of the file.


  • So, how do I detect the end of file when I am using byte arrays like this? Or is there an even bigger issue.



     
    Bartender
    Posts: 9626
    16
    Mac OS X Linux Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Report post to moderator
    Please do not post the same topic more than once.
    CarefullyChooseOneForum
     
      Bookmark Topic Watch Topic
    • New Topic