Take the 2-minute tour ×  I should made a server & client in
Java,based on Swing and gui.I neeed to make somehow a socket
that will go from the server to the client and from the client
to the server, and will pass some kind of a string.I would like
to have later a function that would do several things according
to the string that would be in the socket. For some reason I
couldn't find a simple example for code that shows how it's done
in a simple way. Anyone has any simple example or can explain
how is it being done?  share|improve this question  2 Answers 2
Based on this example, here's a simple network client-server
pair using Swing. Note some issues related to correct
synchronization: The GUI itself is constructed on the event
dispatch thread using invokeLater(). In addition, the code
relies on the thread safety of append(). Finally, it
incorporates a handy tip from the article Text Area Scrolling.
Update: In Java 7, append() is no longer marked as thread safe;
invokeLater() is used in display() to seque