a
554325746@qq.com
2019-12-25 38492bbaa63586e2f4877da0eaa01a082fd565a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.basic.security.utils;
 
//import nanomsg.reqrep.RepSocket;
//import nanomsg.reqrep.ReqSocket;
//
//public class JnanomsgServer {
//    private static String url = "tcp://0.0.0.0:7789";
//
//    public static void main(String[] args) {
//        receive();
////        send();
//    }
//    public static void receive() {
//        System.out.println("JnanomsgServer.receive");
//        final RepSocket socket = new RepSocket();
//        socket.setRecvTimeout(-1);
//        socket.bind(url);
//        new Thread(new Runnable() {
//            public void run() {
//                while (true) {
//                    try {
//                        System.out.println( "received:" + socket.recvString());  // 阻塞socket,直到超时或者有响应
//                        Thread.sleep(1000);
//                        socket.send("received");
//
//                    } catch (Exception e) {       // 忽略超时
////                        e.printStackTrace();
//                        System.out.println(e.getMessage());
//                    }
//                }
//            }
//        }).start();
//    }
//
////    private static void send() {
////        final ReqSocket socket = new ReqSocket();
////        socket.connect(url);
////        new Thread(new Runnable() {
////            public void run() {
////                while (true) {
////                    try {
////                        socket.send("hello");
////                        Thread.sleep(1000);
////                        System.out.println( "node0:" + socket.recvString());  // 阻塞socket,直到超时或者有响应
////                    } catch (InterruptedException e) {
////                        e.printStackTrace();
////                    } catch (Exception e) {
////                        // e.printStackTrace();
////                    }
////                }
////            }
////        }).start();
////    }
//}