Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6812803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:29:38+00:00 2026-05-26T20:29:38+00:00

If I connect to an inexistent socket with pyzmq I need to hit CTRL_C

  • 0

If I connect to an inexistent socket with pyzmq I need to hit CTRL_C to stop the program. Could someone explay why this happens?

import zmq

INVALID_ADDR = 'ipc:///tmp/idontexist.socket'

context = zmq.Context()
socket = context.socket(zmq.REQ)

socket.connect(INVALID_ADDR)
socket.send('hello')

poller = zmq.Poller()
poller.register(socket, zmq.POLLIN)
conn = dict(poller.poll(1000))
if conn:
    if conn.get(socket) == zmq.POLLIN:
        print "got result: ", socket.recv(zmq.NOBLOCK)
else:
    print 'got no result'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:29:38+00:00Added an answer on May 26, 2026 at 8:29 pm

    This question was also posted as a pyzmq Issue on GitHub. I will paraphrase my explanation here (I hope that is appropriate, I am fairly new to SO):

    A general rule: When in doubt, hangs at the end of your zeromq program are due to LINGER.

    The hang here is caused by the LINGER socket option, and happens in the context.term() method called during garbage collection at the very end of the script. The LINGER behavior is described in the zeromq docs, but to put it simply, it is a timeout (in milliseconds) to wait for any pending messages in the queue to be handled after closing the socket before dropping the messages. The default behavior is LINGER=-1, which means to wait forever.

    In this case, since no peer was ever started, the ‘hello’ message that you tried to send is still waiting in the send queue when the socket tries to close. With LINGER=-1, ZeroMQ will wait until a peer is ready to receive that message before shutting down. If you bind a REP socket to ‘ipc:///tmp/idontexist.socket’ while this script is apparently hanging, the message will be delivered and the script will finish exiting cleanly.

    If you do not want your script to wait (as indicated by your print statements that you have already given up on getting a reply), set LINGER to any non-negative value (e.g. socket.linger = 0), and context.term() will return after waiting the specified number of milliseconds.

    I should note that the INVALID_ADDR variable name suggests an understanding that connection to an interface that does not yet have a listener is not valid – this is incorrect. zeromq allows bind/connect events to happen in any order, as illustrated by the behavior described above, of binding a REP socket to the interface while the sending script is blocking on term().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Facebook Connect and their Social Widgets documentation mention that you need to add an
How do I connect to a remote Oracle database instance from PHP? I need
My application has to connect to PC via WiFi.I need to scan and display
ImageView connect = (ImageView) findViewById(R.id.fconnect); connect.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { facebook.authorize(SignIn.this,
I connect to some program via COM and receive System.__ComObject. I know several methods
I connect to a web service with this client that work fine: WSCSI WSCS
I can connect to a linked server with this: SELECT testNo, soruTuruId, soruNo, cevap
I need to connect to a nexus repo of mine, but I'd also like
to connect to facebook, i've placed this in body tag: <body> <div id=fb-root></div> <script>
Using connect, express, and socket.io, I'm trying to allow my application to grab the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.