服务器端用RpcServerUseAllProtseqs注册之后,客户端用ncacn_ip_tcp连接时应该怎么写?
用RpcStringBindingCompose(NULL,"ncacn_ip_tcp",NULL,NULL,NULL,&szStringBinding),然后再用RpcBindingFromStringBinding(szStringBinding,&IF_ClientIfHandle),结果执行调用时异常,RpcExceptionCode返回RPC_S_INVALID_BINDING.

解决方案 »

  1.   

    下面我把具体代码贴上来吧
    服务器端:
    RPC_STATUS status;
    unsigned char * pszAutoEntryName    = (unsigned char*)"/.:/implicit_IFLink";
    unsigned char * pszSecurity         = NULL;
    unsigned int    cMinCalls           = 1;
    unsigned int    cMaxCalls           = RPC_C_LISTEN_MAX_CALLS_DEFAULT;
    unsigned int    fDontWait           = FALSE;
    unsigned int    fNameSyntaxType     = RPC_C_NS_SYNTAX_DEFAULT; status = RpcServerRegisterIf(IFLink_ServerIfHandle,
       NULL, 
       NULL);
    if(status)
    return; status = RpcServerUseAllProtseqs(RPC_C_PROTSEQ_MAX_REQS_DEFAULT,NULL); if(status)
    return; RPC_BINDING_VECTOR* pBindingVector=NULL;
    status = RpcServerInqBindings(&pBindingVector); if(status)
    return; status = RpcNsBindingExport(fNameSyntaxType,
      pszAutoEntryName,
      IFLink_ServerIfHandle,
      pBindingVector,
      NULL);
    if(status)
    return; status=RpcEpRegister(IFLink_ServerIfHandle,
    pBindingVector,
    NULL,NULL);
    if(status)
    return; status = RpcServerListen(cMinCalls,
       cMaxCalls,
       fDontWait);
    if(status)
    return;客户端RPC_STATUS status; status = RpcStringBindingCompose(
           NULL,
           (unsigned char*)"ncacn_ip_tcp",
           pServerIP,
    NULL,
    NULL,
    &szStringBinding); if (status)
    return 0; status = RpcBindingFromStringBinding(
           szStringBinding,
           &IFLink_ClientIfHandle);用的是implicit_handle,如果用auto_handle的话倒是能连上,应该能说明服务器端没什么大问题吧