Skip to content

sockopt::rcvtimeo argument too small #642

@jwmelto

Description

@jwmelto

I'm updating legacy code to use the new socket options, and ran into an issue:

error: no matching function for call to 'zmq::socket_t::set(const zmq::sockopt::rcvtimeo_t& std::chrono::duration<long int, std::ratio<1, 1000> >::rep)'

The calling user code is like this:

void Send(zmq::socket_t& sock, std::chrono::milliseconds timeout) {
    sock.set(zmq::sockopt::rcvtimeo, timeout.count());
...
}

A richer interface would accept a (templated?) std::chrono::duration, but the specific issue here is the definition of sockopt::rcvtimeo uses int and template substitution fails when provided a long int (std::chrono::milliseconds::rep).

Simply changing the definition of rcvtimeo to take a long int breaks code like

sock.set(zmq::sockopt::rcvtimeo, 42);

and the enumeration-as-helper-type pattern precludes overloads. I don't see a good solution to this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions