Skip to content

Feature: OS-chosen port available to application #703

Description

@eile

Use case: I want to let the OS choose the port by supplying port 0 during initialization. This allows multiple applications to run concurrently, and the actual port will be communicated e.g. through zeroconf to the user.

I need to know the port chosen from the application, e.g., by having an API on the server to query the used address and port.

For example, in https://github.com/HBPVIS/ZeroEQ/blob/0.6.0/tests/http/server.cpp#L244 the URI has port 0 by default, and the URI returned after initialization in line 255 will contain the chosen port so that the client can connect to the server.

API proposal:

class Server
{
    std::string port() const; // >0 after listen, 0 otherwise
    std::string address() const;
};

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions