Skip to main content

Summary This article describes how to access the client's hostname or IP address on the server side
Article Number 27356
Environment Orbix 6 All Supported Operating Systems
Question/Problem Description How to retrieve client's IP address in Orbix servant?
How to retrieve client's hostname on the server side?
How to identify where a client invocation has came from?
Clarifying Information
Error Message
Defect/Enhancement Number
Cause
Resolution The attached demo based on the Orbix simple demo shows how to print out the client IP address on the server side.

C :

// Obtain a reference to an IT_GIOP::Current2 object 
IT_GIOP::Current2_var giop_current2; 
CORBA::Object_var objref2 = m_orb->resolve_initial_references("IT_GIOPCurrent"); 
giop_current2 = IT_GIOP::Current2::_narrow(objref2); 
if (CORBA::is_nil(giop_current2.in()) ) { 
    // Error: Narrow failed.... 
    cerr << "Narrow failed" << endl;
    return; 
CORBA::String_var ra_string = giop_current2->remote_address_literal(); 
cout << "Remote address = " << ra_string << endl;

JAVA:

    try {
        org.omg.CORBA.Object obj =
           Server.global_orb.resolve_initial_references("IT_GIOPCurrent");
        com.iona.corba.IT_GIOP.Current2 giop_current =
           com.iona.corba.IT_GIOP.Current2Helper.narrow(obj);
        System.out.println("Remote address: " giop_current.remote_address_literal());
    } catch (Exception ex) {
        ex.printStackTrace();
    }


 
Workaround
Notes
Attachment http://community.microfocus.com/cfs-file.ashx/__key/communityserver-wikis-components-files/00-00-00-01-55/8272.simple.clientip.zip

Created date: 19 December 2011
Last Modified: 13 February 2013
Last Published: 12 May 2012
First Published date: 19 December 2011

#Orbix
#KnowledgeDocs