• 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

Client/server - message getting delayed..

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am facing a strange problem.
I have implemented a Client/Server app with client in C and server in Java. Server is a multithreaded app using JDBC (having DB Connection pools).
Sometimes when the client sends the message, server doesn't receive in the first attempt. After many retries it receives. Client side there is not delay.
This is happening very rarely though. I have set all tcp socket properties (TCPNODELAY, SocketTimeout etc).
Here is the piece of code on server which reads the message.
// in - socket inputstream
try {
int len = in.available();
if (debug1)
System.out.println("Available bytes: " + len);
int retries = 0;
while ((len <= 0) && (retries++ < 35))
{
try {
Thread.sleep(100);
} catch (Exception e) {}
len = in.available();
if (debug0)
System.out.println("Reading again: "+retries+" "+len);
}
byte [] b = new byte[BUF_SIZE];
// read all bytes
nread = in.read(b);
bin.write(b, 0, nread);
b = null;
}
catch (Exception e) {}
Sometimes it reads after 22 retries (that is more than 2 secs). I am running this application on Solaris 2.5
When I do netstat -a on client side, I see the Send-Q is having the message.
If the message is written on client side why it takes so much time on server side??
 
reply
    Bookmark Topic Watch Topic
  • New Topic