/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
#include <time.h>
#ifdef _WIN32_
#include <winsock2.h>
#else 
#include <sys/time.h>
#endif

int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
    struct timeval *timeout) {
    void *fptr;
    int retval;

#ifdef _WIN32_
    fptr = dlsym(_ChSysSocket_handle, "select_chdl");
#else 
    fptr = dlsym(_ChSysTime_handle, "select_chdl");
#endif

    if(fptr == NULL)  {
       printf("Error: %s(): dlsym(): %s\n", __func__, dlerror());
       return -1;
    }
    dlrunfun(fptr, &retval, select, nfds, readfds, writefds, exceptfds, 
              timeout);
    return retval;
}
