0 Replies Latest reply on Jun 16, 2010 9:59 AM by SOMEONEINTHEWORLD

    policy file request

    SOMEONEINTHEWORLD Level 1

      Hello,

       

      I am trying to connect to java server.  I am getting the error policy file request.  i included the policy file in the below code, i am not sure whether i am doing the right thing.  Can anyone please tell me how to do it.

       

      import java.io.*;
      import java.net.*;

       

      public class TCPServer extends Thread {
         public static void main(String[] argv) throws IOException {
         new TCPServer().start();
         }

       

         /** The hang-around time */
         final static int MINUTES = 1;
         /** The port number */
         public final static int PORT = 1234;
         /** The server socket. */
         ServerSocket ss;

       

         /** Constructor -- just creates the ServerSocket */
         public TCPServer() throws IOException {
            ss = new ServerSocket(PORT);
         }

       

         public void run() {
            while (true) {
               try {
               System.out.println("SocketServer waiting for connection");
               Socket s = ss.accept();

       

               String str = "<?xml version=\"1.0\"?>" +
                      "<cross-domain-policy>" +
                      "<allow-access-from domain=\"*\" />" +
                      "</cross-domain-policy>";

       

               BufferedReader is = new BufferedReader(
                  new InputStreamReader(s.getInputStream()));
               PrintWriter pout = new PrintWriter(s.getOutputStream(), true);

       

               pout.println(str);
               String name = is.readLine();
               System.out.println(name);
               String passwd = is.readLine();
               String domain = is.readLine();
              
               pout.println("Welcome to " + domain + ", " + name);
               } catch (IOException e) {
                  System.err.println("Oh, dear me! " + e);
               }
            }
         }
      }

       

      Thanks