Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The Code:
- import io.ktor.network.sockets.*
- import kotlinx.coroutines.experimental.*
- import java.net.*
- fun main(args: Array<String>) {
- runBlocking {
- val a: ASocket =ASocket
- val socket = ASocket().tcp().connect(InetSocketAddress("127.0.0.1", 2323))
- val input = socket.openReadChannel()
- val output = socket.openWriteChannel(autoFlush = true)
- output.writeBytes("hello\r\n")
- val response = input.readASCIILine()
- println("Server said: '$response'")
- }
- }
- The error:-
- /Programming_Workspace/Ma_Currents/KtorExample/src/main/kotlin/com/otakusenpai/KtorExample/main.kt: (8, 22): Interface ASocket does not have constructors
- Gradle script:-
- group 'KtorExample'
- version '1.0-SNAPSHOT'
- buildscript {
- ext.kotlin_version = '1.2.31'
- ext.ktor_version = '0.9.1'
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
- }
- }
- apply plugin: 'java'
- apply plugin: 'kotlin'
- sourceCompatibility = 1.8
- compileKotlin {
- kotlinOptions.jvmTarget = "1.8"
- }
- compileTestKotlin {
- kotlinOptions.jvmTarget = "1.8"
- }
- kotlin {
- experimental {
- coroutines "enable"
- }
- }
- repositories {
- jcenter()
- maven { url "https://dl.bintray.com/kotlin/ktor" }
- }
- dependencies {
- compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
- compile "io.ktor:ktor-server-netty:$ktor_version"
- compile "io.ktor:ktor-network:$ktor_version"
- }
- jar {
- manifest {
- attributes 'Class-Path': '/build/libs/aghotabot.jar'
- attributes 'Main-Class': 'com.otakusenpai.KtorExample.MainKt'
- }
- from {
- configurations.compile.collect {
- it.isDirectory() ? it : zipTree(it)
- }
- }
- }
Add Comment
Please, Sign In to add comment