client-server communication

Hi!

I'm trying to write a midlet that communicates with a server running on a PC. (with a Socket connection). On the emulator everything works fine. On the phone, the app connects to the server but then it is not able to send any message to it. I tried with different methods.

I tried using writeUTF() and readUTF() on the DataOutputStream and DataInputStream; I tried with a BufferedReader and a PrintWriter and I tried writing directly the bytes on the OutputStream. All the methods works in the emulator, none works on the phone. Have any of you had similar problems?

I'm using a nokia N93 and GPRS for communication

Thanks

Eve

anja

[680 byte] By [anjaa] at [2007-11-27 6:21:13]
# 1
Exceptions? Returned values? Logs?You should give more details.
learnphysicsa at 2007-7-12 17:37:30 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

ok...no exception.....the server just keeps waiting and nothing comes from the client....I just can't understand what is going wrong since on the emulator everything works....i'm lost :P

if u have some example of client-server communication that works on an actual cell phone, I would be very glad :)

ps....is there a way to have some more information about what's going on in the phone? I tried to print exceptions on the screen but apparentely there is no exception. (i just know from the server that the client actually open the connection with it)

Message was edited by:

anja

anjaa at 2007-7-12 17:37:30 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3

Try to find line where execution stops.

..........

PrintOnScreen.print("line 100");

anyFunc();

PrintOnScreen.print("line 102");

..................

May be anyFunc() is synchronized, somewhat inside anyFunc() is syncronized or function waits for something.

Does readUTF play role of anyFunc in your case?

Try using flush() (when writing)

check what result available() returns

(Returns the number of bytes that can be read from this input stream without blocking.)

Message was edited by:

learnphysics

Message was edited by:

learnphysics

learnphysicsa at 2007-7-12 17:37:30 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4
thank u for your help..now it works!!!
anjaa at 2007-7-12 17:37:30 > top of Java-index,Java Mobility Forums,Java ME Technologies...