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();
try{
if(buttonPressed.equals("search")){
String name=kfc.getText(); //kfc is the textfield where a name is entered to search on
String x;
x="<"+name;
out.println(x);
String text;
while ((text = in.readLine()) != null) //in is the bufferedReader
{
System.out.println(text);
out.println("search info received");
}
in.close(); //may not need this here
}
} catch (IOException f){
System.out.println("Read failed");
System.exit(1);
}
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()
{
outer.println(e.nextElement());
}
Any tips would be greatly appreciated.