Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy does my program skip the if statement
    primarykey
    data
    text
    <p>I have this tcp/ip program, where if the user enter's "Bye." it would stop the connection, and end the program. However, when I type Bye. from the client side, it won't do the if statement, but rather the other.</p> <p>part of the program</p> <pre><code>while ((inputLine = in.readLine()) != null) { System.out.println ("Server: " + inputLine); out.println(inputLine); String csvline = getCsvLineVal (getLocation34CSV(getTag34Value(Tag34Location(getTagCSV( parseFixMsg(inputLine ,inputLine))), getValueCSV( parseFixMsg(inputLine ,inputLine))), getVal34(input1, input2)), getCSVLine( input3, input4) ); compareClientFixCSV( getTagCSV( parseFixMsg(inputLine ,inputLine)), getValueCSV(parseFixMsg(inputLine ,inputLine)), getCSVTag(csvline), getCSVValue(csvline)); if (inputLine.equals("Bye.")) { System.out.println("Exit program"); break; } out.close(); in.close(); clientSocket.close(); serverSocket.close(); } </code></pre> <p>larger part of the program</p> <pre><code>public static void server(Scanner input1, Scanner input2, Scanner input3, Scanner input4) throws IOException{ ServerSocket serverSocket = null; try { serverSocket = new ServerSocket(57634); } 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 = new PrintWriter(clientSocket.getOutputStream(), true); BufferedReader in = new BufferedReader( new InputStreamReader( clientSocket.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) { System.out.println ("Server: " + inputLine); out.println(inputLine); String csvline = getCsvLineVal (getLocation34CSV(getTag34Value(Tag34Location(getTagCSV( parseFixMsg(inputLine ,inputLine))), getValueCSV( parseFixMsg(inputLine ,inputLine))), getVal34(input1, input2)), getCSVLine( input3, input4) ); compareClientFixCSV( getTagCSV( parseFixMsg(inputLine ,inputLine)), getValueCSV(parseFixMsg(inputLine ,inputLine)), getCSVTag(csvline), getCSVValue(csvline)); if (inputLine.equals("Bye.")) { System.out.println("Exit program"); break; } out.close(); in.close(); clientSocket.close(); serverSocket.close(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload