Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Echo-server/Kotlin/echo-server.kotlin
Normal file
25
Task/Echo-server/Kotlin/echo-server.kotlin
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import java.net.ServerSocket
|
||||
import java.net.Socket
|
||||
|
||||
fun main() {
|
||||
|
||||
fun handleClient(conn: Socket) {
|
||||
conn.use {
|
||||
val input = conn.inputStream.bufferedReader()
|
||||
val output = conn.outputStream.bufferedWriter()
|
||||
|
||||
input.forEachLine { line ->
|
||||
output.write(line)
|
||||
output.newLine()
|
||||
output.flush()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ServerSocket(12321).use { listener ->
|
||||
while (true) {
|
||||
val conn = listener.accept()
|
||||
Thread { handleClient(conn) }.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue