File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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.
 
wood burning stoves
 
subject: Plz help to solve it.
 
Similar Threads
Chat At Server Part Both write and read at the same time?
accessing a server using socket connection
I/O stream from Socket not ready
Client Server Communication
Dynamic IP address and socket programming.