• Post Reply Bookmark Topic Watch Topic
  • New Topic

Delayed or No Response from zbp socket server  RSS feed

 
Abdullah Khan
Greenhorn
Posts: 3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I am trying to write a java socket program which sends request to a ZBP server.
I hav been succesfull in sending the request (an XML) to the server and also the server from its side sends a response. I could see this reponse data in the logs of the server.
However, I am facing problem where, the response (an XML) is not received at my java program at all or the response is received, but after a long time (after 3mins), during which my session for next request expires at the server's end.

Could someone please give me some pointer on what could be the problem and where my code is going wrong ?
I am providing my code snippet below.

Further, this is the same program that I have written while triggering a socket connection from my Andorid application.
Even from the Android application (from the Android Development Tools IDE and also my test device) I face the same problem - the request is sent to the server and the server sends a resposne, but it never reaches my machine or my program does not capture it.
Any pointers in this regard will be really helpful.



Regards,
Abdullah
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. I would do an explicit flush() to the printWriter just to be sure.
2. I would never trust a readLine() to do what you expect - it may just hang waiting for a cr or lf that never comes. Just read character by character so you can see what is happening.

Bill
 
Abdullah Khan
Greenhorn
Posts: 3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for the input you provided. Reading character by character instead of readLine() helped me in solving my problem.
Also, to be on the safer side, I have done a explicit flush of the write-logic.

Regards,
Abdullah.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To elaborate on Bill's point #2 you may wish to read Don't println to a Socket. It's a universal problem, not limited to any particular OS.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!