Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitor sockets #103

Open
yan-zaretskiy opened this issue Dec 4, 2020 · 3 comments
Open

Monitor sockets #103

yan-zaretskiy opened this issue Dec 4, 2020 · 3 comments

Comments

@yan-zaretskiy
Copy link

I'm really excited about this project. Looking forward to dropping the libzmq dependency from my code in favour of zmq.rs. My usage of ZemoMQ is rather lightweight, in fact you already support the features I use (ROUTER/DEALER over TCP). One thing that I think you don't have yet are monitor sockets. I find them very useful when monitoring the connection state. I'm curious whether they are on your Roadmap somewhere in the future? :-)

@Alexei-Kornienko
Copy link
Collaborator

I see a following possible solution:

  1. create a monitor method on socket. This will create a mpsc channel that will be used to receive monitor events (and give you back a consumer).
  2. Create SocketEvent enum for all events (http://api.zeromq.org/4-1:zmq-socket-monitor)

What is not fully clear is what kind of payload should be in this events. Cause for C++ for example spec says "The event value is the file descriptor (FD) of the underlying network socket. Warning: there is no guarantee that the FD is still valid by the time your code receives this event."

I think I will start with some basic implementation of events and we'll have to see what payload actually makes sense for each event type.

@yan-zaretskiy
Copy link
Author

I am not at all familiar with zmq.rs yet, so feel free to discard anything I say. The thought I have is that however you choose to signal the monitor events should use the same mechanism that you use for polling other ZeroMQ sockets in your crate, to mimic how it's done in the regular ZeroMQ library.

As for the payload, again, I am a total noob, but judging by that warning, the FD payload is pretty much useless, so perhaps a plain enum without data would suffice.

Alexei-Kornienko added a commit that referenced this issue Dec 10, 2020
Initial version of socket monitor impl. Related to #103
@jfrader
Copy link

jfrader commented Jul 6, 2024

Is there any examples on how to check if the connection has dropped? Im trying to figure this out for a while and don't know how to use the monitor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants