5 Replies Latest reply: Feb 21, 2012 3:42 PM by EJP RSS

    I got a problem connecting server using two systems

    916889
      Hi peoples,
      I got a problem while connecting server and client using two independent systems.The same program is working in same machine as a server and client.i here mention the programs.
      im using netbeans

      **Client program:**

      String address=jTextField1.getText().trim(); //got ip address of server from textfield
      System.out.println(address);
      Socket client;

      try {
      InetAddress adressen = InetAddress.getByName(address);
      client = new Socket(adressen, 4444);
      BufferedReader scanf = new BufferedReader(new InputStreamReader(client.getInputStream()));
      String someString = scanf.readLine();
      System.out.println("From Server: " + someString);
      jLabel2.setText("From Server :"+someString);
      client.close();
      } catch (Exception e) {
      System.out.println(e);
      }


      SErver PRogram:
      try {
      ServerSocket listener = new ServerSocket(4444);
      while (!finished) {
      Socket to_client = listener.accept();
      String address=InetAddress.getLocalHost().getHostAddress();

      System.out.println(address);
      //jTextField1.setText(address);
      OutputStream out = to_client.getOutputStream();
      PrintWriter pout = new PrintWriter(out, true);
      pout.println("Hello! this is server talking to you.");
      to_client.close();
      }
      listener.close();
      }// end of try
      catch (Exception ie) {
      System.out.println(ie);
      }


      Help me people to find out the solutions
      Note Guys Program working in same machine as server and client but not working in two independent machine as client and server

      mail me also <email address removed by moderator>





      --
      Edited by: rukbat on Feb 11, 2012 1:23 PM
      Your email address has been removed.
      Requests for communication beyond the forums defeats the whole reason for having forums (you would be hiding possible solutions from everyone else).

      Additionally, showing your email address in a world-readable public forum invites harvesters to spam you for all eternity.