Forums Register Login

Client/server - message getting delayed..

+Pie Number of slices to send: Send
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??
Good night. Drive safely. Here's a tiny ad for the road:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 945 times.
Similar Threads
File Transfer via Sockets
Not getting the bytes sent
FTP(File transfer)
Presenting image read from database in a html page
Java net BindException:Address already in use: JVM_Bind
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:27:57.