i was following the code examples from here <https...
# ktor
o
i was following the code examples from here https://ktor.io/servers/raw-sockets.html
d
It is
aSocket
with
a
in lower case just like in the documentation.
Copy code
val socket = aSocket().tcp().connect(InetSocketAddress("127.0.0.1", 2323))
o
Ok Ill try, thnx
👍 1
what is the type of socket here?
i see this errors coming up,/home/neelz/Programming_Workspace/Ma_Currents/KtorExample/src/main/kotlin/com/otakusenpai/KtorExample/main.kt: (12, 16): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: public fun File.writeBytes(array: ByteArray): Unit defined in kotlin.io e: /home/neelz/Programming_Workspace/Ma_Currents/KtorExample/src/main/kotlin/com/otakusenpai/KtorExample/main.kt: (13, 30): Unresolved reference: readASCIILine
d
are you using intellij?
Copy code
import io.ktor.network.sockets.*
import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.io.*
import java.net.*

fun main(args: Array<String>) {
    runBlocking {
        val server = aSocket().tcp().bind(InetSocketAddress(“127.0.0.1”, 2323))
        println(“Started echo telnet server at ${server.localAddress}“)

        while (true) {
            val socket = server.accept()

            launch {
                println(“Socket accepted: ${socket.remoteAddress}“)

                val input = socket.openReadChannel()
                val output = socket.openWriteChannel(autoFlush = true)

                try {
                    while (true) {
                        val line = input.readASCIILine()

                        println(“${socket.remoteAddress}: $line”)
                        output.writeBytes(“$line\r\n”)
                    }
                } catch (e: Throwable) {
                    e.printStackTrace()
                    socket.close()
                }
            }
        }
    }
}
you can press
alt+return
and select
Import
to add the right imports

http://oi67.tinypic.com/1247b5x.jpg

o
ok, Im new to IntelliJ so idk but thnx 🙂
d

http://oi65.tinypic.com/mlgtck.jpg

http://oi68.tinypic.com/30swv2b.jpg

you can also use
alt+return
to specify type explicitly and see of what type a expression is
o
ok
thnx
d
np