• Post Reply Bookmark Topic Watch Topic
  • New Topic

Chat room server not receiving messages from client  RSS feed

 
Heg Lachher
Greenhorn
Posts: 28
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have server and client code for a chat room and the problem is that whenever I send a message from my client the server never receives it.
Also the WindowListener also doesn't work.

Server code:



Client code:
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this was my problem I would create the smallest possible test case client and server without all the interface stuff and get that working first.

Bill
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sample has Swing UI code in it.

Swing cannot be used for UI purposes in a webapp. But I'm not sure this is a webapp. If it isn't, this is the wrong forum to ask in. If it is, the webapp needs to be redesigned.
 
Heg Lachher
Greenhorn
Posts: 28
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:If this was my problem I would create the smallest possible test case client and server without all the interface stuff and get that working first.

OK, William Brogden, I have made this without all the interface stuff though is still does not work. The new code is shown below.

Client Code:




Server code:
 
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
still does not work


Is not very informative, what actually happens? Describe what you did to test and what happened on both client and server end.

Bill
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure you're not running into this problem: Don't println to a Socket - it is NOT Mac-specific, and you ARE using readLine and println.
 
Heg Lachher
Greenhorn
Posts: 28
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I have found out one of the problems. The problem I have found out is that I wasn't flushing my PrintWriters after using them though the WindowListener still doesn't work.
New Code:

Server:




Client:



Still need help with the WindowListener though!
All Help Appreciated!
 
Heg Lachher
Greenhorn
Posts: 28
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Make sure you're not running into this problem: Don't println to a Socket - it is NOT Mac-specific, and you ARE using readLine and println.


The only reason I didn't do this is because the newLine() method AutoFlushes.
I probably will just flush it myself though.
 
Heg Lachher
Greenhorn
Posts: 28
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Moved to a more appropriate forum.

Where?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!