_DISTRIBUTED OBJECTS AND THE INTERNET_ by John Pompeii Listing One // file: connctsv.idl #include struct TimeStamp; enum NPConnectStatus { NPConnected, NPDisconnected, NPTrying }; // structure to define a TCP/IP interface struct NetworkPort { unsigned long handle; string port_name; string attached_network; NPConnectStatus status; unsigned short connections; long last_error; long last_drverror; }; // defines a typed array of NetworkPort structures typedef sequence NetworkPortList; // structure definition for specific connection struct NetConnection { string port_name; HConnect hcnct; string user_name; string user_host; TimeStamp connectTime; }; typedef sequence NetConnectionList; typedef sequence TelephoneNumberList; stuct NetworkDef; { string netname; unsigned long address; string description; TelephoneNumberList phoneNumbers; string setup; }; typedef sequence NetworkList; // exceptions exception ctsvException { long errorCode; long driverCode; }; // Internet Connection Service interface (class) definition interface ConnectService : SOMDServer { HConnect connect(in string network) raises(ctsvException); void disconnect(in HConnect hcnct) raises(ctsvException); boolean is_connected(in string network) raises(ctsvException); void exchange_events(in HConnect hcnct) raises(ctsvException); NetworkPort get_port(in HConnect hcnct) raises(ctsvException); unsigned short get_port_count(); void list_ports(out NetworkPortList ports); void list_connections(out NetConnectionList cncts); void list_networks(out NetworkList nets); #ifdef __SOMIDL__ implementation { releaseorder : connect, disconnect, is_connected, exchange_events, get_port, get_port_count, list_ports, list_connections, list_networks; callstyle=idl; dllname = "ctserv.dll"; memory_management = corba; majorversion = 1; minorversion = 0; somDefaultInit: override, init; somDestruct: override; }; #endif }; Listing Two void LISAAppFrame :: ConnectNetwork(NetworkDef *net, LISAEnv *appl) { Environment *ev = __SOMenv; // obtain a proxy object to the ICS by asking DSOM for the service by its // alias name. (defined when the server was installed in the system) ConnectService *ctsv = (ConnectService *) SOMD_ObjectMgr->somdFindServerByName(ev, "connectService"); if (!ev->OK()) throw CORBA::SystemException(ev); // now that have the server object, initiate the connection: HConnection handle = ctsv->connect(ev, net->netname); if (ev->OK()) { // network connection established OK, now attempt Oracle logon // connection. First, build the Oracle SQL*Net connection // string: "userid/password@t:netname" char signOn[80]; sprintf(signOn, "%s/%s@t:%s", appl->user, appl->password, net->netname); try { // connect the the database via the persistence driver appl->oracleDb->Connect(signon); // Done! Save the connection handle and return appl->hConnect = handle; } catch(...) { // No go. Either the database is down or the user does not have // permission to access the database. Cancel the connection to the // remote network and return the error to the caller. ctsv->disconnect(ev, handle); throw; } } else throw CORBA::SystemException(ev); } void LISAAppFrame :: DisconnectNetwork(LISAEnv *appl) { Environment *ev = __SOMenv; // connect the the database via the persistence driver appl->oracleDb->Disconnect(); // obtain a proxy object to the ICS from DSOM ConnectService *ctsv = (ConnectService *) SOMD_ObjectMgr->somdFindServerByName(ev, "connectService"); if (!ev->OK()) throw CORBA::SystemException(ev); // now that we have the server object, destroy the connection: ctsv->disconnect(ev, appl->hConnect); appl->hConnect = NULLHANDLE; } Example 1: Property Name Type Value "Street" tc_STRING "220 Center St." "City" tc_STRING "Mentor" "State" tc_STRING "OH" "ZipCode" tc_LONG 44060