1 Reply Latest reply: Jan 2, 2004 4:30 PM by 807582 RSS

    performance problems with java sockets

    807582
      Hi ,

      I written a server class that simply writes the numbers and the client simply reads those numbers and prints them. When I run the both client and server on tha same machine there is no data loss found. But when I run the server on different machine than client I found heavy dataloss.(while theserver written numbers from 1-9000 the client is able read only 6000 plus). The data loss is increased when the data read from the server socket created by the VB application. Here with i am pasting the code snippet for the Server and the Client java files . Please help me in solving this problem.


      Client.java
      --------------
      import java.net.*;
      import java.io.*;

      public class Client
      {
           static Socket client = null;
           ObjectInputStream is = null;

           public Client() throws Exception
           {
                client = new Socket("rajsekhar",3333);

                is = new ObjectInputStream (client.getInputStream());

                while(true){
                     Integer in = (Integer)is.readObject();
                     System.out.println(in.toString());
                }
           }

           public static void main(String[] args) throws Exception
           {
                new Client();
           }

      }


      Server.java
      --------------
      import java.net.*;
      import java.io.*;

      public class Server
      {
           public static void main(String[] args) throws Exception
           {
                ServerSocket server = null;
                server = new ServerSocket(3333);
                Socket s = server.accept();
                ObjectOutputStream os = new ObjectOutputStream(s.getOutputStream());
                int i =1;
                while(true)
                {
                     os.writeObject(new Integer(i));
                     System.out.println(i);
                     i++;
                }
           }
      }

      please help me .

      thanks in advance,

      Sridhar Reddy .R