• Post Reply Bookmark Topic Watch Topic
  • New Topic

message from server = null?

 
kelvin cheung
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I am trying to send some messages from the server to the client program.

Here are some my code for the server:



Here are some of the code of the client:


I get this :
Message from server: null

I have tested the contents of "dataFromFile". It's not "null".

I should also have seen this :
Server connection established


How comes??
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you flush the PrintWriter before closing the Socket?
 
kelvin cheung
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

I get this when I write flush() :

Server connection established


But I should also have got the contents of :


 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You only read one line from the server before exiting as the first readLine() is commented out. What happens if you uncomment that line? Even better, try putting this in your client:This will print out every line sent by the server.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!