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 "SocketRead er", and is coded as follows:
import java.io.*;
import java.net.*;
public class socketReader implements Runnable{
BufferedReader readMessage;
String message="";
synchronized String socketReader(So cket client){
Thread t=new Thread(this);
t.start();
public void run(){
try{
//while(true){
readMessage=new BufferedReader( new InputStreamRead er
(client.getInpu tStream()));
message=readMes sage.readLine() ;
readMessage.clo se();
//}
}
catch (IOException ioex){
System.out.prin tln("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
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 "SocketRead er", and is coded as follows:
import java.io.*;
import java.net.*;
public class socketReader implements Runnable{
BufferedReader readMessage;
String message="";
synchronized String socketReader(So cket client){
Thread t=new Thread(this);
t.start();
public void run(){
try{
//while(true){
readMessage=new BufferedReader( new InputStreamRead er
(client.getInpu tStream()));
message=readMes sage.readLine() ;
readMessage.clo se();
//}
}
catch (IOException ioex){
System.out.prin tln("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
Comment