[zeromq-dev] AttributeError when using getpeername

Emile Achadde emile.achadde at free.fr
Wed Dec 26 17:44:30 CET 2018


here is a small script that gives "AttributeError: Socket has no such 
option: GETPEERNAME" why ?

import zmq
import random
import sys
import time

port = "15556"
context = zmq.Context()
socket = context.socket (zmq.PAIR)
socket.bind ("tcp://*:%s" % port)

while True:
     socket.send (b"Server message to client")
     message_b = socket.recv()
     message_s = message_b.decode ("utf-8")
         (ip_client, port) = socket.getpeername ()
         print ("Connected to '%s:%s'" % (ip_client, port))
     except NameError:
         print ("Erreur pas de client connecté")

     print ("received message from client '%s'" % message_s)

More information about the zeromq-dev mailing list