Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Help need for client server program

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

i was trying to come up with a program where the client would be sending a audio file to a server and the server would be saving it. I am unable to find what is wrong with my program (it's getting stuck) can some one help me with this program.


Server program:



Client program:


JCE: UseCodeTags
 
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is it getting "stuck"?
 
avinash reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

This morning i tried the same program in Linux it worked fine but was not working in windows system. The server is unable to read the final few bytes of data and is getting stuck ...


 
avinash reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
its is not coming out of the while loop
 
Rancher
Posts: 43024
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which while loop? There are several. Which of the conditions for loop termination is not being satisfied?

You're explicitly checking for character #13, which is a carriage return. Are you sure one is being sent? That's one of the differences between Unix and Windows.

(As an aside, I'd also simplify the code by removing all unnecessary code. For example, "InputStreamReader isr" and "PrintWriter os" are not being used in the server code, so you should delete all traces of them, lest they interfere with the code's operation.)
 
avinash reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sorry for not providing the complete information

It's actually getting stuck in the 34 line ( while(currentsize<size&&(character=is.read(buffer))!=-1) ) in the Server program. Most of the file is getting transfered but by the time it reaches the last few bytes of the file its just getting stuck. I even tried to debug it in eclipse debug mode but could not trace anything.
 
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