-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
michael-conway
committed
Jul 22, 2016
1 parent
cbf26d0
commit b8d0abf
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
zeromq-provider/src/main/java/org/irods/jargon2/provider/zeromq/sandbox/ZeromqProvider.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,36 @@ | ||
/** | ||
* | ||
*/ | ||
package org.irods.jargon2.provider.zeromq.sandbox; | ||
|
||
import org.zeromq.ZMQ; | ||
|
||
/** | ||
* Test simple socket provider for zeromq | ||
* @author mconway | ||
* | ||
*/ | ||
public class ZeromqProvider { | ||
|
||
|
||
public static void main(String[] args) { | ||
ZMQ.Context context = ZMQ.context(1); | ||
|
||
// Socket to talk to server | ||
System.out.println("Connecting to hello world server…"); | ||
|
||
ZMQ.Socket requester = context.socket(ZMQ.REQ); | ||
requester.connect("tcp://localhost:5555"); | ||
|
||
for (int requestNbr = 0; requestNbr != 10; requestNbr++) { | ||
String request = "Hello"; | ||
System.out.println("Sending Hello " + requestNbr); | ||
requester.send(request.getBytes(), 0); | ||
|
||
byte[] reply = requester.recv(0); | ||
System.out.println("Received " + new String(reply) + " " + requestNbr); | ||
} | ||
requester.close(); | ||
context.term(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
zeromq-provider/src/main/java/org/irods/jargon2/provider/zeromq/sandbox/package-info.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,7 @@ | ||
|
||
/** | ||
* throw away sandbox to start playing with zeromq | ||
* @author mconway | ||
* | ||
*/ | ||
package org.irods.jargon2.provider.zeromq.sandbox; |
38 changes: 38 additions & 0 deletions
38
...emulator/src/main/java/org/irods/jargon2/provider/zeromq/sandbox/server/ZeromqServer.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,38 @@ | ||
/** | ||
* | ||
*/ | ||
package org.irods.jargon2.provider.zeromq.sandbox.server; | ||
|
||
import org.zeromq.ZMQ; | ||
|
||
/** | ||
* Simple server side of straight-ahead zeromq point to point socket | ||
* @author mconway | ||
* | ||
*/ | ||
public class ZeromqServer { | ||
|
||
public static void main(String[] args) throws Exception { | ||
ZMQ.Context context = ZMQ.context(1); | ||
|
||
// Socket to talk to clients | ||
ZMQ.Socket responder = context.socket(ZMQ.REP); | ||
responder.bind("tcp://*:5555"); | ||
|
||
while (!Thread.currentThread().isInterrupted()) { | ||
// Wait for next request from the client | ||
byte[] request = responder.recv(0); | ||
System.out.println("Received Hello"); | ||
|
||
// Do some 'work' | ||
Thread.sleep(1000); | ||
|
||
// Send reply back to client | ||
String reply = "World"; | ||
responder.send(reply.getBytes(), 0); | ||
} | ||
responder.close(); | ||
context.term(); | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
...emulator/src/main/java/org/irods/jargon2/provider/zeromq/sandbox/server/package-info.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,6 @@ | ||
/** | ||
* Play sandbox for server side of zeromq | ||
* @author mconway | ||
* | ||
*/ | ||
package org.irods.jargon2.provider.zeromq.sandbox.server; |