Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to get a FIX message from the client side to server side, where I created a UI for the server. The only problem is that, when I try to output the message onto the textarea, it won't update, while the rest of the program work, such as the text fields will all properly update, when called. I have the action event put onto a button click.

I put the output of the message inside a while loop, does that affect the way it outputs?

problem area
Java
String inputLine, outputLine;
      try {
		while ((inputLine = in.readLine()) != null) 
		      { 
		       System.out.println ("Server: " + inputLine); 
		       
		       tfFIXMsg.append(  inputLine+ "\n\n\n");

action event
Java
   /** ActionEvent handler - Called back when user clicks the button. */
   @Override
   public void actionPerformed(ActionEvent evt) {
    // Get the String entered into the TextField tfPort, convert to int
      port = Integer.parseInt(tfPort.getText());


      fileLocation = tfLocation.getText();
      String csvName = fileLocation;


  ServerSocket serverSocket = null;

  try {
       serverSocket = new ServerSocket(port);
      }
  catch (IOException e)
      {
       System.err.println("Could not listen on port: 57635.");
       System.exit(1);
      }

  Socket clientSocket = null;
  System.out.println ("Waiting for connection.....");

  try {
       clientSocket = serverSocket.accept();
      }
  catch (IOException e)
      {
       System.err.println("Accept failed.");
       System.exit(1);
      }

  System.out.println ("Connection successful");
  System.out.println ("Waiting for input.....");

  PrintWriter out = null;
try {
    out = new PrintWriter(clientSocket.getOutputStream(),
                                        true);
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
  BufferedReader in = null;
try {
    in = new BufferedReader(
              new InputStreamReader( clientSocket.getInputStream()));
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

  String inputLine, outputLine;

  try {
    while ((inputLine = in.readLine()) != null)
          {
           System.out.println ("Server: " + inputLine);



           tfFIXMsg.append(  inputLine+ "\n\n\n");



           if (inputLine.trim().equals("Bye.")) {
               System.out.println("Exit program");
               break;
               }

           Scanner input1 = new Scanner(new File(csvName));
           Scanner input2 = new Scanner(new File(csvName));
           Scanner input3 = new Scanner(new File(csvName));
           Scanner input4 = new Scanner(new File(csvName));


           String csvline = getCsvLineVal (getLocation34CSV(getTag34Value(Tag34Location(getTagCSV( parseFixMsg(inputLine ,inputLine))), getValueCSV( parseFixMsg(inputLine ,inputLine))), getVal34(input1,  input2)), getCSVLine( input3,  input4) );
           outputLine = compareClientFixCSV( getTagCSV( parseFixMsg(inputLine ,inputLine)), getValueCSV(parseFixMsg(inputLine ,inputLine)), getCSVTag(csvline), getCSVValue(csvline));

           out.println(outputLine);
           tfCSVLine.setText(outputLine);
           input1.close();
           input2.close();
           input3.close();
           input4.close();



          }
} catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}


  out.close();
  try {
    in.close();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
  try {
    clientSocket.close();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
  try {
    serverSocket.close();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
   }

More Specifically
Java
tfFIXMsg.append(  inputLine+ "\n\n\n");
Posted
Updated 7-Aug-13 6:49am
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900