summaryrefslogtreecommitdiffstats
path: root/external_libs/python/pyzmq-14.7.0/examples/security/grasslands.py
blob: 2e36ab62c845c7ef5f0348e068f09c510cc2a58b (plain)
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
#!/usr/bin/env python

'''
No protection at all.

All connections are accepted, there is no authentication, and no privacy. 

This is how ZeroMQ always worked until we built security into the wire 
protocol in early 2013. Internally, it uses a security mechanism called 
"NULL".

Author: Chris Laws
'''

import zmq


ctx = zmq.Context.instance()

server = ctx.socket(zmq.PUSH)
server.bind('tcp://*:9000')

client = ctx.socket(zmq.PULL)
client.connect('tcp://127.0.0.1:9000')

server.send(b"Hello")
msg = client.recv()
if msg == b"Hello":
    print("Grasslands test OK")