• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sending string using writeUTF

 
Anjali Malar
Greenhorn
Posts: 6
Java MyEclipse IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi all,
I have been using Java Ranch for a long time. But this is my first post. Happy to interact with you all.

I am writing a client server program as a part of project. In that the client need to send parts of file (size varies from 256 bytes to 64KB ) to server.
So I used DataOutputStream and writeUTF(String s) method to send the file parts.
But the problem is server is able to get the first part and for second part it is not receiving.
I like to know is there any size constraints in string size we are sending in writeUTF() method? Can it send 64KB data to server ?

Thanks

 
Jared Malcolm
Ranch Hand
Posts: 54
Java MySQL Database PHP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see nothing in the documentation that points towards a limitation....

readUTF();

writeUTF();

possibly provide some code to point towards an answer?
 
Yunnan Zhou
Ranch Hand
Posts: 31
C++ Java MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
readUTF and writeUTF are obstruction methods.
try readUTF in you server.
just like you wirte a message,the server must read it.or it will be obstructed
I hope this will help you.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Can you show us some of your source code, especially the side that is receiving the string?

I suspect you might have an error like the issue described here: Read Doesn't Do What You Think It Does.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's an obstruction method?
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think he means a blocking method.
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jared Malcolm wrote:I see nothing in the documentation that points towards a limitation....

.... except this?
First, the total number of bytes needed to represent all the characters of s is calculated. If this number is larger than 65535, then a UTFDataFormatException is thrown.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:I think he means a blocking method.
Thank you
 
Jared Malcolm
Ranch Hand
Posts: 54
Java MySQL Database PHP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:
Jared Malcolm wrote:I see nothing in the documentation that points towards a limitation....

.... except this?
First, the total number of bytes needed to represent all the characters of s is calculated. If this number is larger than 65535, then a UTFDataFormatException is thrown.


Good call, I guess I didn't include this due to his max size fitting within this (figured there was probably some other issue) according to his original post. Since his max file size is at the threshold of how large he can transmit I'd probably recommend breaking it into parts first...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic