if (!sock) return CMTFailure;
nsPSMShimConnect(CMTSocket sock, short port, char *path){    PRStatus    err;    PRErrorCode errcode;    CMTStatus   rv = CMTSuccess;    CMSocket    *cmSock = (CMSocket *)sock;    if (cmSock->isUnix)    {#ifndef XP_UNIX        return CMTFailure;#else        int pathLen;        if (!path)        {            return CMTFailure;        }        /* check buffer overrun */        pathLen = strlen(path)+1;                pathLen = pathLen < sizeof(cmSock->netAddr.local.path)                ? pathLen : sizeof(cmSock->netAddr.local.path);          memcpy(&cmSock->netAddr.local.path, path, pathLen);        cmSock->netAddr.local.family = PR_AF_LOCAL;#endif    }    else  /* cmSock->isUnix */    {        cmSock->netAddr.inet.family = PR_AF_INET;        cmSock->netAddr.inet.port   = PR_htons(port);        cmSock->netAddr.inet.ip     = PR_htonl(PR_INADDR_LOOPBACK);    }    err = PR_Connect( cmSock->fd, &cmSock->netAddr, PR_INTERVAL_MAX );        if (err == PR_FAILURE)        {        errcode = PR_GetError();                /* TODO: verify PR_INVALID_ARGUMENT_ERROR continue with connect */                switch (errcode)        {            case PR_IS_CONNECTED_ERROR:                rv = CMTSuccess;                break;            case PR_IN_PROGRESS_ERROR:            case PR_IO_TIMEOUT_ERROR:#ifdef WIN32            case PR_WOULD_BLOCK_ERROR:                        case PR_INVALID_ARGUMENT_ERROR:#endif            default:                rv = CMTFailure;                break;        }    }        return rv;}