libs/stream_message/src/transport.cxx
// ===========================================================================
// Connect to a given service, calling back client.communicate()
// once the connection is made.  When client.communicate() returns,
// end the connection.
//
// Returns false if no connection was made.
//
Connect to a given service, calling back client.communicate()
once the connection is made.  When client.communicate() returns,
end the connection.

Returns false if no connection was made.
Connect to a given service calling back client . communicate () once the connection is made . When client . communicate () returns end the connection . Returns false if no connection was made .
bool nTransport::connect_generic(
			  const ServicePort &service, void *clientp,
			  void (*clientCommunicate)(void *, int, void *),
			  string **diagnostic,
			  void *connectionp)
{
    if (diagnostic != NULL) {
	*diagnostic = NULL;
    }
    bool isOK = false;
    int port;
    int addr;
    if (!initialize()) {
	if (diagnostic != NULL) {
	    *diagnostic = new string("Failed to initialize sockets.");
	}
    }
    else if (!service.getPortAndAddr(port, addr, diagnostic)) {
	if (diagnostic != NULL) {
	    if (*diagnostic == NULL) {
		*diagnostic = new string("Failed to get port and address for service.");
	    }
	    else {
		string svc_diag = **diagnostic;
		**diagnostic = "Failed to get port and address for service, because ";
		(*diagnostic)->append(svc_diag);
		(*diagnostic)->append(".");
	    }
	}
    }
    else {
	string *diag;
	int connected_sock = ConnectToServer(port, addr, &diag);
	if (connected_sock >= 0) {
    	    isOK = true;
	    clientCommunicate(clientp, connected_sock, connectionp);
	}
	else {
	    if (diagnostic != NULL) {
		*diagnostic = new string("Failed to make connection to service");
		if (diag != NULL) {
		    (*diagnostic)->append(", because ");
		    (*diagnostic)->append(*diag);
		    delete diag;
		}
		(*diagnostic)->append(".");
	    }
	}
    }
    return isOK;
}
bool nTransport :: connect_generic ( const ServicePort & service , void * clientp , void ( * clientCommunicate ) ( void * , int , void * ) , string * * diagnostic , void * connectionp ) { if ( diagnostic != NULL ) { * diagnostic = NULL ; } bool isOK = false ; int port ; int addr ; if ( ! initialize ( ) ) { if ( diagnostic != NULL ) { * diagnostic = new string ( " " ) ; } } else if ( ! service . getPortAndAddr ( port , addr , diagnostic ) ) { if ( diagnostic != NULL ) { if ( * diagnostic == NULL ) { * diagnostic = new string ( " " ) ; } else { string svc_diag = * * diagnostic ; * * diagnostic = " " ; ( * diagnostic ) -> append ( svc_diag ) ; ( * diagnostic ) -> append ( " " ) ; } } } else { string * diag ; int connected_sock = ConnectToServer ( port , addr , & diag ) ; if ( connected_sock >= 0 ) { isOK = true ; clientCommunicate ( clientp , connected_sock , connectionp ) ; } else { if ( diagnostic != NULL ) { * diagnostic = new string ( " " ) ; if ( diag != NULL ) { ( * diagnostic ) -> append ( " " ) ; ( * diagnostic ) -> append ( * diag ) ; delete diag ; } ( * diagnostic ) -> append ( " " ) ; } } } return isOK ; }
Connect to a given service, calling back client.communicate()
once the connection is made.
Connect to a given service calling back client . communicate () once the connection is made .
// Process the connection.