Last active
April 5, 2019 17:43
-
-
Save thealmikey/16b1ce2af8dac23a87a070a663c7d622 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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