File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
kotlinx-coroutines-nio/src/test/kotlin/kotlinx/coroutines/experimental/nio Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,6 @@ import kotlin.test.assertEquals
16
16
import kotlin.test.assertTrue
17
17
18
18
class AsyncIOTest {
19
- val PORT = Random ().nextInt(10000 ) + 10000 // randomize port for this test
20
-
21
19
@Rule
22
20
@JvmField
23
21
val tmpDir = TemporaryFolder ()
@@ -66,7 +64,9 @@ class AsyncIOTest {
66
64
val serverChannel =
67
65
AsynchronousServerSocketChannel
68
66
.open()
69
- .bind(InetSocketAddress (PORT ))
67
+ .bind(InetSocketAddress (0 ))
68
+
69
+ val serverPort = (serverChannel.localAddress as InetSocketAddress ).port
70
70
71
71
val c1 = launch(CommonPool ) {
72
72
val client = serverChannel.aAccept()
@@ -83,7 +83,7 @@ class AsyncIOTest {
83
83
val connection =
84
84
AsynchronousSocketChannel .open()
85
85
// async calls
86
- connection.aConnect(InetSocketAddress (" 127.0.0.1" , PORT ))
86
+ connection.aConnect(InetSocketAddress (" 127.0.0.1" , serverPort ))
87
87
connection.aWrite(Charsets .UTF_8 .encode(" OK" ))
88
88
89
89
val buffer = ByteBuffer .allocate(3 )
You can’t perform that action at this time.
0 commit comments