Skip to content

Instantly share code, notes, and snippets.

@thealmikey
Last active April 5, 2019 17:32
Show Gist options
  • Save thealmikey/dafc0346083f549f248841e1f1a668db to your computer and use it in GitHub Desktop.
Save thealmikey/dafc0346083f549f248841e1f1a668db to your computer and use it in GitHub Desktop.
import org.zeromq.ZMQ
fun main() {
val context = ZMQ.context(1)
val socket = context.socket(ZMQ.REP)
println("Starting the server...")
socket.bind("tcp://*:5897")
while (true) {
val rawRequest = socket.recv(0)
val cleanRequest = String(rawRequest, 0, rawRequest.size - 1)
println("Request received : $cleanRequest")
var plainReply = "World "
var rawReply = plainReply.toByteArray()
rawReply[rawReply.size - 1] = 0
socket.send(rawReply, 0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment