ASC_associationWaiting(T_ASC_Network * network, int timeout)
{
#ifdef _WIN32
    SOCKET s;
#else
    int s;
#endif
    struct timeval t;
    int nfound;

    if (network == NULL) return OFFalse;

    s = DUL_networkSocket(network->network);

#ifdef _WIN32
    if (s == INVALID_SOCKET) return OFFalse;
#else
    if (s < 0)
        return OFFalse;
#endif

#ifndef DCMTK_HAVE_POLL
    fd_set fdset;
    FD_ZERO(&fdset);
#ifdef __MINGW32__
    // on MinGW, FD_SET expects an unsigned first argument
    FD_SET((unsigned int) s, &fdset);
#else
    FD_SET(s, &fdset);
#endif /* __MINGW32__ */
#endif /* DCMTK_HAVE_POLL */
    t.tv_sec = timeout;
    t.tv_usec = 0;

#ifdef DCMTK_HAVE_POLL
    struct pollfd pfd[] =
    {
        { s, POLLIN, 0 }
    };
    nfound = poll(pfd, 1, t.tv_sec*1000+(t.tv_usec/1000));
#else
#ifdef HAVE_INTP_SELECT
    nfound = select(OFstatic_cast(int, s + 1), (int *)(&fdset), NULL, NULL, &t);
#else
    // the typecast is safe because Windows ignores the first select() parameter anyway
    nfound = select(OFstatic_cast(int, s + 1), &fdset, NULL, NULL, &t);
#endif /* HAVE_INTP_SELECT */
#endif /* DCMTK_HAVE_POLL */
    if (DCM_dcmnetLogger.isEnabledFor(OFLogger::DEBUG_LOG_LEVEL))
    {
      DU_logSelectResult(nfound);
    }
    return nfound > 0;
}
ASC_associationWaiting(T_ASC_Network * network, int timeout)
{
#ifdef _WIN32
    SOCKET s;
#else
    int s;
#endif
    struct timeval t;
    int nfound;

    if (network == NULL) return OFFalse;

    s = DUL_networkSocket(network->network);

#ifdef _WIN32
    if (s == INVALID_SOCKET) return OFFalse;
#else
    if (s < 0)
        return OFFalse;
#endif

#ifndef DCMTK_HAVE_POLL
    fd_set fdset;
    FD_ZERO(&fdset);
#ifdef __MINGW32__
     
    FD_SET((unsigned int) s, &fdset);
#else
    FD_SET(s, &fdset);
#endif  
#endif  
    t.tv_sec = timeout;
    t.tv_usec = 0;

#ifdef DCMTK_HAVE_POLL
    struct pollfd pfd[] =
    {
        { s, POLLIN, 0 }
    };
    nfound = poll(pfd, 1, t.tv_sec*1000+(t.tv_usec/1000));
#else
#ifdef HAVE_INTP_SELECT
    nfound = select(OFstatic_cast(int, s + 1), (int *)(&fdset), NULL, NULL, &t);
#else
     
    nfound = select(OFstatic_cast(int, s + 1), &fdset, NULL, NULL, &t);
#endif  
#endif  
    if (DCM_dcmnetLogger.isEnabledFor(OFLogger::DEBUG_LOG_LEVEL))
    {
      DU_logSelectResult(nfound);
    }
    return nfound > 0;
}