Home Help Center

When using SSL protocol, get IP and port in the program

J_X_ZJ_X_Z Member zhouOrganization: PersonalProject: communication

When I use TCP protocol, I can obtain IP and port dynamically in the following ways:

auto v = adapter->getEndpoints();
auto in1 = v[0]->getInfo();
Ice::TCPEndpointInfoPtr t = Ice::TCPEndpointInfoPtr::dynamicCast(in1);

So how do I get IP and port number when I use SSL Protocol?

Tagged:

Best Answer

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Accepted Answer

    EndpointInfo uses composition to provide info about the different transports, you can get the TCPEndpoint info by checking the underlying endpoint info, something like

    Ice::TCPEndpointInfoPtr
    getTCPEndpointInfo(const Ice::EndpointInfoPtr& info)
    {
        for(Ice::EndpointInfoPtr p = info; p; p = p->underlying)
        {
            Ice::TCPEndpointInfoPtr tcpInfo = Ice::TCPEndpointInfoPtr::dynamicCast(p);
            if(tcpInfo)
            {
                return tcpInfo;
            }
        }
        return 0;
    }
    

Answers

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Accepted Answer

    EndpointInfo uses composition to provide info about the different transports, you can get the TCPEndpoint info by checking the underlying endpoint info, something like

    Ice::TCPEndpointInfoPtr
    getTCPEndpointInfo(const Ice::EndpointInfoPtr& info)
    {
        for(Ice::EndpointInfoPtr p = info; p; p = p->underlying)
        {
            Ice::TCPEndpointInfoPtr tcpInfo = Ice::TCPEndpointInfoPtr::dynamicCast(p);
            if(tcpInfo)
            {
                return tcpInfo;
            }
        }
        return 0;
    }
    
  • J_X_ZJ_X_Z Member zhouOrganization: PersonalProject: communication

    Thank you very much for your help, let me solve the problem

Sign In or Register to comment.