wood burning stoves 2.0*
The moose likes Sockets and Internet Protocols and the fly likes Help need for client server program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Help need for client server program" Watch "Help need for client server program" New topic

Help need for client server program

avinash reddy

Joined: Jun 09, 2009
Posts: 5

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
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
Where is it getting "stuck"?

"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
avinash reddy

Joined: Jun 09, 2009
Posts: 5

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

Joined: Jun 09, 2009
Posts: 5
its is not coming out of the while loop
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41060
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.)

Ping & DNS - my free Android networking tools app
avinash reddy

Joined: Jun 09, 2009
Posts: 5

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.
I agree. Here's the link: http://aspose.com/file-tools
subject: Help need for client server program
Similar Threads
Read, Send, Write a File through a socket
How to Change the File Name for Each Uploaded Files to the Socket Server?
Sending a file over socket
A good, simple tutorial for making sockets work over the Internet.
FileOutputStream code is not executing in Socket server program