https://kotlinlang.org logo
#ktor
Title
d

Deactivated User

04/18/2018, 10:47 AM
^ @otakusenpai
o

otakusenpai

04/18/2018, 10:48 AM
thank you very much
also can you help me with the second one?
d

Deactivated User

04/18/2018, 10:48 AM
Try something like:
Copy code
val stringBuilder = StringBuilder()
input.readUTF8LineTo(stringBuilder)
o

otakusenpai

04/18/2018, 10:49 AM
ok
d

Deactivated User

04/18/2018, 10:49 AM
For the second one, aSocket is not a class, but a construction function
o

otakusenpai

04/18/2018, 10:49 AM
oh
socket = aSocket().tcp().bind(InetSocketAddress(address,port)).accept()
so what is the return type of this?
d

Deactivated User

04/18/2018, 10:50 AM
Copy code
val socket: Socket = aSocket().tcpNoDelay().tcp().connect(address)
o

otakusenpai

04/18/2018, 10:50 AM
ok
is it java.net.Socket?
d

Deactivated User

04/18/2018, 10:51 AM
As a small trick, if you need to know the type of a expression you can type:
Copy code
val socket = aSocket().tcpNoDelay().tcp().connect(address)
Then put the cursor over
val socket
, and press
alt+return
then
Specify type explicitly
. In this case, the fqname is:
io.ktor.network.sockets.Socket
o

otakusenpai

04/18/2018, 10:52 AM
oh, the ide is pointing to java.net.socket
many thanks 🙂
d

Deactivated User

04/18/2018, 10:52 AM
Using the
Specify type explicitly
?
o

otakusenpai

04/18/2018, 10:52 AM
yes
d

Deactivated User

04/18/2018, 10:53 AM
I have tried, and it adds the right import after doing it and pressing return twice
o

otakusenpai

04/18/2018, 10:53 AM
oh wait theres also a option for io.ktor...
i didnt look at it
my bad
d

Deactivated User

04/18/2018, 10:53 AM
But shouldn’t be necessary.
okay
o

otakusenpai

04/18/2018, 10:54 AM
anyways many thanks again 😄
d

Deactivated User

04/18/2018, 10:54 AM
You are welcome 🙂