Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AWT-server socket issue

Jeremy Quartey
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing a client server application based on server sockets. The client has a GUI written in AWT and the server has methods to process requests sent to it from the client
I have successfully made a connection between server and client and sent requests and received requests using matching pairs of BufferedReaders and PrintWriters. In the actionPerformed of the client the printWriter will send out requests depending on which button is pressed and the buffered reader on the server will receive the request and the relevant processing should commence. The server PrintWriter should then send the result back to the clients BufferedReader
[1] The first problem is that when I send a request to the server to return the result of a search the application locks when there are multiple lines of text in the reply which for the moment I am just outputting to the client's system out.
[2] The second issue is that once I resolve the locking issue above I want to change from printing the results of queries to the system.out and instead update text components in the client GUI with the information returned. There is a list component and two textfield components which should display info related to the item selected in the list.

If you know how to get round this please let me know and I can send you further code if necessary:
I think this is where part of the problem is:
In client:
public void actionPerformed( ActionEvent e ) {
String buttonPressed=e.getActionCommand();
String name=kfc.getText(); //kfc is the textfield where a name is entered to search on
String x;
String text;
while ((text = in.readLine()) != null) //in is the bufferedReader
out.println("search info received");
in.close(); //may not need this here
} catch (IOException f){
System.out.println("Read failed");

In the server:
do {
s = br.readLine();
if(s.startsWith("<")) {
String y=s.substring(1,s.length());
for (Enumeration e=membs.getMember(y);e.hasMoreElements() {

Any tips would be greatly appreciated.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic