Skip to content

Instantly share code, notes, and snippets.

@thealmikey
Last active April 5, 2019 17:43
Show Gist options
  • Save thealmikey/16b1ce2af8dac23a87a070a663c7d622 to your computer and use it in GitHub Desktop.
Save thealmikey/16b1ce2af8dac23a87a070a663c7d622 to your computer and use it in GitHub Desktop.
org.zeromq.ZMQ
fun main() {
val context = ZMQ.context(1)
val socket = context.socket(ZMQ.REQ)
println("connecting to hello world server...")
socket.connect("tcp://localhost:5897")
for (i in 1..10) {
var plainRequest = "Hello "
var byteRequest = plainRequest.toByteArray()
byteRequest[byteRequest.size - 1] = 0
println("sending request $i $plainRequest")
socket.send(byteRequest, 0)
val byteReply = socket.recv(0)
var plainReply = String(byteReply, 0, byteReply.size - 1)
println("Received reply $plainReply")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment