Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Client/server - message getting delayed..

 
gupta boddu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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??
 
The moth suit and wings road is much more exciting than taxes. Or this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!