Guest User

Untitled

a guest
Apr 13th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. The Code:
  2.  
  3. import io.ktor.network.sockets.*
  4. import kotlinx.coroutines.experimental.*
  5. import java.net.*
  6.  
  7. fun main(args: Array<String>) {
  8. runBlocking {
  9. val a: ASocket =ASocket
  10. val socket = ASocket().tcp().connect(InetSocketAddress("127.0.0.1", 2323))
  11. val input = socket.openReadChannel()
  12. val output = socket.openWriteChannel(autoFlush = true)
  13.  
  14. output.writeBytes("hello\r\n")
  15. val response = input.readASCIILine()
  16. println("Server said: '$response'")
  17. }
  18. }
  19.  
  20. The error:-
  21. /Programming_Workspace/Ma_Currents/KtorExample/src/main/kotlin/com/otakusenpai/KtorExample/main.kt: (8, 22): Interface ASocket does not have constructors
  22.  
  23. Gradle script:-
  24.  
  25. group 'KtorExample'
  26. version '1.0-SNAPSHOT'
  27.  
  28. buildscript {
  29. ext.kotlin_version = '1.2.31'
  30. ext.ktor_version = '0.9.1'
  31.  
  32. repositories {
  33. mavenCentral()
  34. }
  35. dependencies {
  36. classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  37. }
  38. }
  39.  
  40. apply plugin: 'java'
  41. apply plugin: 'kotlin'
  42.  
  43. sourceCompatibility = 1.8
  44. compileKotlin {
  45. kotlinOptions.jvmTarget = "1.8"
  46. }
  47. compileTestKotlin {
  48. kotlinOptions.jvmTarget = "1.8"
  49. }
  50.  
  51. kotlin {
  52. experimental {
  53. coroutines "enable"
  54. }
  55. }
  56.  
  57. repositories {
  58. jcenter()
  59. maven { url "https://dl.bintray.com/kotlin/ktor" }
  60. }
  61.  
  62. dependencies {
  63. compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
  64. compile "io.ktor:ktor-server-netty:$ktor_version"
  65. compile "io.ktor:ktor-network:$ktor_version"
  66. }
  67.  
  68. jar {
  69. manifest {
  70. attributes 'Class-Path': '/build/libs/aghotabot.jar'
  71. attributes 'Main-Class': 'com.otakusenpai.KtorExample.MainKt'
  72. }
  73. from {
  74. configurations.compile.collect {
  75. it.isDirectory() ? it : zipTree(it)
  76. }
  77. }
  78. }
Add Comment
Please, Sign In to add comment