• 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
  • 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

messages sent via sockets get truncated

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to send large messages (~60,000 bytes) over sockets. For some reason, my messages always get truncated at 15,392 or 15,840 bytes. Can anyone help? Here is sample of my code:
public void run()
{
try
{
int bytesAvailable = in.available();
while(bytesAvailable == 0) {
try {
sleep(20);
bytesAvailable = in.available();
}
catch(InterruptedException ie) {
}
}
// Read 8 1-K packets for a total of 8K message
byte[]b = new byte[(1024 * 8)];
int readCount = 0;
int offSet = 0;
StringBuffer sb = new StringBuffer();

while((readCount = in.read(b,0,b.length))!= -1)
{
if(readCount < 8192)
{
sb.append(new String(b,0,readCount));
break;
}
sb.append(new String(b));
}
Thank-you...
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see anything wrong with your code here. I have heard of this problem occuring if your URL string doesn't exactly match the case of the URL for the server, check that. If your still having this problem, let us know.
 
Every time you till, you lose 30% of your organic matter. But this tiny ad is durable:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic