HOw can i read from a socket and display message from socket in Textarea of Chatpanel even if there is no any focus in Chatpanel.I mean when i create two chatpanel instance then after clicking the send button in 1st chatpanel the message from socket should be displayed in Textarea of second chatpanel without performing any action in second chatpanel.
47pirates
9
Junior Poster in Training
Recommended Answers
Jump to PostIf both panels are running on the same machine,, then why not just have Chatpanel 1 call an update method in Chatpanel2?
If they are on different machines, then the standard solution is to implement a Listener interface for the receiver socket code. The code for Chatpanel2 should register itself …
Jump to PostYour reading thread sits in a loop waiting for input to arrive at its socket. When input arrives you call the Listener's method to display that input, then loops round to wait for the next input.
Jump to PostHey there, hmmm well i would say take a look here and study these codes to better understand sockets and multithreaded clients and servers:http://pirate.shu.edu/~wachsmut/Teaching/CSAS2214/Virtual/Lectures/chat-client-server.html
Jump to PostThere's more than one way. Post you latest reader code so we can use that as the starting point.
Jump to PostI don't see any Socket code there - have you started it yet? If not, just do a really simple one that just send/recieves a single line and prints it out and exits. You can incorporate that code into the real multi-threaded system when it's working.
All 24 Replies
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
47pirates
9
Junior Poster in Training
47pirates
9
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
DavidKroukamp
105
Master Poster
Team Colleague
Featured Poster
47pirates
9
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
47pirates
9
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
47pirates
9
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
47pirates
9
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
47pirates
9
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
47pirates
9
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
47pirates
9
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
47pirates
9
Junior Poster in Training
47pirates
9
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
47pirates
9
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.