zmq python 代码

neu_yanggx neu_yanggx 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

import zmq
server = "tcp://127..0.0.1:7666"

if __name__ == '__main__':
context = zmq.Context()
sender = context.socket(zmq.REQ)
sender.connect(server)

print "Hello, welcome to [tool]"

# 1.input cmd
while True:
msg_send = raw_input("please input msg:")
print ("sending to %s, msg is: %s" % (server, msg_send))
sender.send(msg_send)

msg_recv = sender.recv()
print ("reply is: %s" % msg_recv)

# 2.open file
# with open('request.txt', 'r') as f:
# msg_send2 = f.read()
#
# print ("sending to %s, msg is: %s" % (server, msg_send2))
# sender.send(msg_send2)
# msg_recv2 = sender.recv()
# print ("reply is: %s" % msg_recv2)

sender.close()
context.term()

发个帖子,记录一下。送分
...全文
评论 2
收藏 已收藏
分享
返回顶部
neu_yanggx
脚本语言 37,737 成员 34,208 内容