Thanks again for the reply.....
Just tell me one thing buddy,
why is this Client Code not giving expected result:
public void run() {
ServerSocket ssoc;
Socket ss,sen;
try {
ss = new Socket(InetAddress.getByName("localhost"),5100);
output = new ObjectOutputStream(ss.getOutputStream());
ssoc = new ServerSocket(5000);
sen = ssoc.accept();
input = new ObjectInputStream(sen.getInputStream());
while(true){
String s = (String) input.readObject();
int i = s.indexOf(",",0);
int j = s.indexOf(",",i+1);
int k = s.indexOf(",",j+1);
String s1 = s.substring(0,i);
String s2 = s.substring(i+1,j);
String s3 = s.substring(j+1);
jTextArea2.append("New Message Recieved and the Details are as under:\n");
jTextArea2.append("Message sent by: "+s1+"\n");
jTextArea2.append("Message subject is: "+s2+"\n");
jTextArea2.append("Actual message is: "+s3+"\n \n \n \n");
jTextArea2.setCaretPosition(jTextArea2.getText().length());
input.close();
}
}
while this modification produces exact desirasable results:
public void run() {
ServerSocket ssoc;
Socket ss, sen;
try {
while (true) {
ss = new Socket(InetAddress.getByName("localhost"), 5100);
output = new ObjectOutputStream(ss.getOutputStream());
ssoc = new ServerSocket(5000);
sen = ssoc.accept();
input = new ObjectInputStream(sen.getInputStream());
String s = (String) input.readObject();
int i = s.indexOf(",", 0);
int j = s.indexOf(",", i + 1);
int k = s.indexOf(",", j + 1);
String s1 = s.substring(0, i);
String s2 = s.substring(i + 1, j);
String s3 = s.substring(j + 1);
jTextArea2.append("New Message Recieved and the Details are as under:\n");
jTextArea2.append("Message sent by: " + s1 + "\n");
jTextArea2.append("Message subject is: " + s2 + "\n");
jTextArea2.append("Actual message is: " + s3 + "\n \n \n \n");
jTextArea2.setCaretPosition(jTextArea2.getText().length());
sen.close();
input.close();
output.close();
ss.close();
ssoc.close();
}