-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JzmqDummyServer.java works with zmqtest.py. So something's wrong with…
… our current camel-zeromq implementation. must fix quickly!
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/main/java/org/opencog/atomspace/zmq/JzmqDummyServer.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.opencog.atomspace.zmq; | ||
|
||
import org.apache.commons.io.HexDump; | ||
import org.zeromq.ZMQ; | ||
|
||
/** | ||
* Created by ceefour on 8/27/15. | ||
*/ | ||
public class JzmqDummyServer { | ||
|
||
public static void main(String... args) throws Exception { | ||
try (final ZMQ.Context context = ZMQ.context(1)) { | ||
try (final ZMQ.Socket socket = context.socket(ZMQ.REP)) { | ||
socket.bind("tcp://127.0.0.1:5555"); | ||
while (!Thread.currentThread ().isInterrupted()) { | ||
byte[] request = socket.recv(0); | ||
HexDump.dump(request, 0, System.out, 0); | ||
|
||
String response = "World"; | ||
socket.send(response.getBytes(), 0); | ||
Thread.sleep(1000); // Do some 'work' | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python | ||
import sys | ||
import time | ||
import zmq | ||
#import TZmqClient | ||
#import thrift.protocol.TBinaryProtocol | ||
#import storage.ttypes | ||
#import storage.Storage | ||
|
||
def main(args): | ||
endpoint = "tcp://127.0.0.1:5555" | ||
socktype = zmq.REQ | ||
# incr = 0 | ||
# if len(args) > 1: | ||
# incr = int(args[1]) | ||
# if incr: | ||
# socktype = zmq.DOWNSTREAM | ||
# endpoint = "tcp://127.0.0.1:9091" | ||
|
||
ctx = zmq.Context() | ||
socket = ctx.socket(socktype) | ||
socket.connect(endpoint) | ||
request = "HELLO" | ||
print "Sending ", request, " ..." | ||
socket.send(request) | ||
message = socket.recv() | ||
print "Received reply: ", message | ||
|
||
#transport = TZmqClient.TZmqClient(ctx, endpoint, socktype) | ||
# protocol = thrift.protocol.TBinaryProtocol.TBinaryProtocolAccelerated(transport) | ||
# client = storage.Storage.Client(protocol) | ||
#transport.open() | ||
# if incr: | ||
# client.incr(incr) | ||
# time.sleep(0.05) | ||
# else: | ||
# value = client.get() | ||
# print value | ||
|
||
if __name__ == "__main__": | ||
main(sys.argv) |