zoukankan      html  css  js  c++  java
  • zeromy quick start

    软件:

    pip install pyzmq

    代码:

    ==server.py

    #  
    #   Hello World server in Python  
    #   Binds REP socket to tcp://*:5555  
    #   Expects "Hello" from client, replies with "World"  
    #  
    import zmq  
    import time  
     
    context = zmq.Context()  
    socket = context.socket(zmq.REP)  
    socket.bind("tcp://*:5555")  
     
    while True:  
        #  Wait for next request from client  
        message = socket.recv()  
        print ("Received request: ", message)
     
        #  Do some 'work'  
        time.sleep (1)        #   Do some 'work'  
     
        #  Send reply back to client  
        socket.send_string("World")  

    ==client.py

    #  
    #   Hello World client in Python  
    #   Connects REQ socket to tcp://localhost:5555  
    #   Sends "Hello" to server, expects "World" back  
    #  
    import zmq  
     
    context = zmq.Context()  
     
    #  Socket to talk to server  
    print ("Connecting to hello world server..."  )
    socket = context.socket(zmq.REQ)  
    socket.connect ("tcp://localhost:5555")  
     
    #  Do 10 requests, waiting each time for a response  
    for request in range (1,10):  
        print ("Sending request ", request,"..."  )
        socket.send_string ("Hello")  
          
        #  Get the reply.  
        message = socket.recv()  
        print ("Received reply ", request, "[", message, "]"  )

    步骤

    打开一个命令行,执行python server.py

    打开一个命令行,执行python client.py

    参考:

    https://blog.csdn.net/kent45/article/details/10397917

  • 相关阅读:
    SSD
    NMS---非极大值抑制
    检测评价函数 IOU
    Ground Truth
    耿建超英语语法---状语从句
    联合索引创建时候的排序规则
    order by limit的原理
    mysql事务四种隔离级别
    为什么 Redis 快照使用子进程
    MYSQL查询~ 存在一个表而不在另一个表中的数据
  • 原文地址:https://www.cnblogs.com/cutepig/p/9170703.html
Copyright © 2011-2022 走看看