Commit 8f1899f4 authored by Trisha Gee's avatar Trisha Gee
Browse files

[Ch15] Test to see if the server port really does change. If it does, it doesn't _appear_ to

parent 32b88860
Loading
Loading
Loading
Loading
+12 −0
Changes for src/test/java/ch15/ConceptsTest.java: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -33,6 +33,18 @@ class ConceptsTest {
    Socket socket = new Socket("localhost", 4242);
  }

  @Test
  void testChannelPortNumbers() throws IOException {
    SocketAddress serverAddress = new InetSocketAddress("127.0.0.1", 3601);
    ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
    serverSocketChannel.bind(serverAddress);

    SocketChannel client1 = SocketChannel.open(serverAddress);
    System.out.println("client1.getRemoteAddress() = " + client1.getRemoteAddress());
    SocketChannel client2 = SocketChannel.open(serverAddress);
    System.out.println("client2.getRemoteAddress() = " + client2.getRemoteAddress());
  }

  @Test
  void testBlockingVsNonBlocking() throws IOException {
    int serverPort = 3600;