my dog learned polymorphism*
The moose likes Sockets and Internet Protocols and the fly likes Plz help to solve it. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Plz help to solve it." Watch "Plz help to solve it." New topic
Author

Plz help to solve it.

Nasir Mkhan
Greenhorn

Joined: May 13, 2001
Posts: 28
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Plz help to solve it.
 
Similar Threads
Chat At Server Part Both write and read at the same time?
Dynamic IP address and socket programming.
Client Server Communication
accessing a server using socket connection
I/O stream from Socket not ready