My last post did not find any replies.I hope I have not offended anyone.I am new in this forum and this is my second post.I am trying to send a message from client to server and back from server to client.In the client window I get a null whereas in the server window the message is printed.
CLIENT
HTML Code:
import java.net.*;
import java.io.*;
import java.lang.*;
public class ClientSort
{
public static void main(String a[])
{
Socket s=null;
try
{
s=new Socket("localhost",6767);
String mes,msg;
BufferedReader in=new BufferedReader(new InputStreamReader(s.getInputStream()));
PrintWriter out=new PrintWriter(new OutputStreamWriter(s.getOutputStream()),true);
mes="Sent";
out.println(mes);
msg=in.readLine();
System.out.println(msg);
}
catch(IOException e)
{
System.out.println(e.getMessage());
}
finally
{
try{
s.close();}
catch(IOException i){System.out.println(i.getMessage());}
}
}
}
HTML Code:
import java.io.*;
import java.lang.*;
class ServerSort
{
public static void main(String a[]) throws IOException
{
ServerSocket ss=new ServerSocket(6767);
Socket s=null;
try
{
String mes,msg;
s=ss.accept();
BufferedReader in=new BufferedReader(new InputStreamReader(s.getInputStream()));
PrintWriter out=new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
mes=in.readLine();
System.out.println(mes);
msg="Received";
out.println(msg);
}
catch(IOException i)
{
System.out.println(i.getMessage());
}
finally
{
try{
s.close();}
catch(IOException io){System.out.println(io.getMessage());}
}
}
}
