Hi there
I am developing a client/server app in Java. I have created a client and a server
via the java.net package. But now i want that ach time the client logs on to the server, a log file is created.
For this i created another class that is used only to read data from the cilent socket and implemented runnable in this class.
Now this reading class is called "SocketReader", and is coded as follows:
import java.io.*;
import java.net.*;
public class socketReader implements Runnable{
BufferedReader readMessage;
String message="";
synchronized String socketReader(Socket client){
Thread t=new Thread(this);
t.start();
public void run(){
try{
//while(true){
readMessage=new BufferedReader(new InputStreamReader
(client.getInputStream()));
message=readMessage.readLine();
readMessage.close();
//}
}
catch (IOException ioex){
System.out.println("Exception: "+ioex);
}
} // run () ends here
return message;
} // constructor ends here
} // class ends here
The problem is that it gives an error message.
Wats going wrong. i've even tried to declare the run() outside the constructor.
Kindly reply