Skip to content

Instantly share code, notes, and snippets.

@mehdisadeghi
Created January 13, 2015 08:18
Show Gist options
  • Select an option

  • Save mehdisadeghi/252895d8264cf36c5743 to your computer and use it in GitHub Desktop.

Select an option

Save mehdisadeghi/252895d8264cf36c5743 to your computer and use it in GitHub Desktop.

Revisions

  1. Mehdi Sadeghi created this gist Jan 13, 2015.
    24 changes: 24 additions & 0 deletions kademlia_get.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #
    # Request-reply client in Python
    # Connects REQ socket to tcp://localhost:5559
    # Sends "Hello" to server, expects "World" back
    #
    import zmq
    import sys

    # Prepare our context and sockets
    context = zmq.Context()
    socket = context.socket(zmq.REQ)
    socket.connect("tcp://localhost:40002")

    # Get request
    socket.send(b"get:", zmq.SNDMORE)
    socket.send(b"the key")
    print socket.recv()

    # and for set
    # Set request
    #socket.send(b"set:", zmq.SNDMORE)
    #socket.send(b"the key", zmq.SNDMORE)
    #socket.send(value)
    #print socket.recv()