Menu

binding a server to a host as well as a port

Help
2003-06-27
2003-06-30
  • Paul S R Chisholm

    Im using XmlRpc++ with great success; but when I start a server, I need to specify the host (IP interface) as well as the port. (I want to be able to run a server bound to the localhost interface, so only processes on the same host can access that server.)

    So, in addition to:

    XmlRpc::XmlRpcServer::bindAndListen(int port, int backlog = 5)

    Id like to have a couple of other interfaces:

    XmlRpc::XmlRpcServer::bindAndListen(const char* host, int port, int backlog)
    XmlRpc::XmlRpcServer::bindAndListen(const std::string& host, int port, int backlog)

    Most or all of these would be think wrappers around a function with the current functionality of bindAndListen().

    I dont think its wise to try to add:

    // no! // XmlRpc::XmlRpcServer::bindAndListen(int hostIP, int port, int backlog)

    since:

    // no! // XmlRpc::XmlRpcServer::bindAndListen(hostIP, port)

    would compile but would not call the right method.

    Also, in addition to:

    XmlRpc::XmlRpcSocket::bind(int port, int backlog)

    wed need at least one of the following (probably the first would be best):

    XmlRpc::XmlRpcSocket::bind(int hostID, int port, int backlog)  // probably
    XmlRpc::XmlRpcSocket::bind(const char* host, int port, int backlog)  // maybe?
    XmlRpc::XmlRpcSocket::bind(const std::string& host, int port, int backlog)  // maybe?

    Sound about right? Suggestions, comments, criticisms?  --PSRC

     
    • Paul S R Chisholm

      > Most or all of these would be think wrappers ...

      Make that "thin wrappers".

      > XmlRpc::XmlRpcSocket::bind(int hostID, int port, int backlog) // probably
      > XmlRpc::XmlRpcSocket::bind(const char* host, int port, int backlog) // maybe?
      > XmlRpc::XmlRpcSocket::bind(const std::string& host, int port, int backlog) // maybe?

      I meant:

      XmlRpc::XmlRpcSocket::bind(int socket, int hostID, int port)
      XmlRpc::XmlRpcSocket::bind(int socket, const char* host, int port)
      XmlRpc::XmlRpcSocket::bind(int socket, const std::string& host, int port)

      I'm getting ambivalent about this.

      On the one hand, there's only one other place in the XmlRpc++ code where a host is passed around, and it's passed around as a string; and I'd like to be consistent about that.

      On the other hand, that would put the host lookup in the XmlRpcSocket class, which doesn't usually check its arguments; so where's the check and error about a bad host name? In XmlRpcSocket::bind()? In XmlRpcServer::bindAndListen()? In both???

       

Log in to post a comment.