• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Plz help to solve it.

 
Nasir Mkhan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I am trying to test this client-server socket communication on stand-alone pc,client program successfully connects to server but empty stream found on client.Plz tell me what is the problem?
Client Program:
InetAddress adress=InetAddress.getLocalHost();
Socket client=new Socket(address,80);
InputStream in=client.getInputStream();
InputStreamReader in2=new InputStreamReader(in);
if(in2.ready())
{
System.out.println(in2.read());
}
*********************
Server Program:
ServerSocket server=new ServerSocket(80);
Socket connection=server.accept();
System.out.println("Client is connected");
OutputStreamWriter out=new OutputStreamWriter (connection.getOutputStream());
out.write("NasirKhan",1,2);
connection.close();
Thanks in any way.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic