Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

Socket Deadlock

Hello,

I have a client server Java application. The client must synchronise data with the server and then close a connection.

Here is a brief summary of the steps :

The client connects to the server socket app and send a START string. The server responds with a READY string. The client then sends it's data to the server . The server will call  readUTF() until the client sends data which includes a special terminating character. the problem is the data with the terminating character in it may get lost and never reach the server. As a result the server is waiting forever, deadlocked. the client too cannot proceed until it has a response from the server.  The client too may become locked if the server's READY string never reaches it.
At the moment I am developing on our LAN and communication is fine, no packets get lost and it all works fine, but the final version is over GPRS and I'm concerned that packets will get lost.

Could someone advice as to how to prevent should deadlock occuring ?

thanks,

Ken
0
kfc23
Asked:
kfc23
  • 4
  • 3
1 Solution
 
TimYatesCommented:
send "AGAIN" messages from the server if it doesn't get a proper response within a specified timeframe?

The clien upon recieving an "AGAIN" message will send the last data it sent again...

That should do it...
0
 
girionisCommented:
Hi kfc23,

If you keep using sockets this will guarantee that packets will arrive and arrive in the order they are sent. I wouldn't worry that much since TCP/IP is an excellent protocol to guarantee data delivery.

What protocol does GPRS use to transfer data?

Regards
0
 
kfc23Author Commented:
not too sure what protocol GPRS uses. i don't think it's as reliable as TCP/IP though.

When creating a socket you can specify a timeout value, which causes the socket to throw an exception when it can't read . I could use this to issue an AGAIN command to the client. Not sure about the client side though. I'm using IMP which is a scaled down version of J2ME. You can't create sockets in the manner you would for a J2SE app so I'm not sure about using the timeout for the client side.

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
girionisCommented:
You can always wait for a response and if you do not get it resent the data. Have a separate thread that does this.

0
 
kfc23Author Commented:
finally got to test over GPRS and the code is stable enough. it seems that GPRS is stable once it establishes an initial connection.
0
 
girionisCommented:
Nice :)

If any of the comments above helped you please accept an answer/split points, otherwise ask a question to community support for zero points to PAQ & refund the points:

http://www.experts-exchange.com/Community_Support/
0
 
kfc23Author Commented:
my only issue now is that  at times it takes up to a minute to connect to our server over GPRS.  depends on the time of the day etc. but thankfully that's not my problem :-) . thanks for the help .
0
 
girionisCommented:
Thank you for accepting :)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now