internal static extern int select(int nfds, [In, Out] fd_set readfds, [In, Out] fd_set writefds, [In, Out] fd_set exceptfds, ref TimeVal timeout);
int ISocketsDriver.select(int nfds, IntPtr readfds, IntPtr writefds, IntPtr exceptfds, ref TimeVal timeout) { List <Socket> readList; List <Socket> writeList; List <Socket> exceptList; int ret = 0; TinyCLRSockets.fd_set read = IntPtrToTinyCLRFdSet(readfds); TinyCLRSockets.fd_set write = IntPtrToTinyCLRFdSet(writefds); TinyCLRSockets.fd_set except = IntPtrToTinyCLRFdSet(exceptfds); if (!TinyCLRFdSetToFdSet(read, out readList)) { return(ReturnError(SocketError.NotSocket)); } if (!TinyCLRFdSetToFdSet(write, out writeList)) { return(ReturnError(SocketError.NotSocket)); } if (!TinyCLRFdSetToFdSet(except, out exceptList)) { return(ReturnError(SocketError.NotSocket)); } if ((readList != null && readList.Count > 0) || (writeList != null && writeList.Count > 0) || (exceptList != null && exceptList.Count > 0)) { try { //Socket.Select(readList, writeList, exceptList, timeout.tv_usec); InternalSelect(readList, writeList, exceptList); } catch (SocketException se) { ret = ReturnError(se.SocketErrorCode); } } if (!FilterFd_set(readList, read)) { return(ReturnError(SocketError.NotSocket)); } if (!FilterFd_set(writeList, write)) { return(ReturnError(SocketError.NotSocket)); } if (!FilterFd_set(exceptList, except)) { return(ReturnError(SocketError.NotSocket)); } TinyCLRFdSetToIntPtr(read, readfds); TinyCLRFdSetToIntPtr(write, writefds); TinyCLRFdSetToIntPtr(except, exceptfds); if (ret != (int)SocketError.SocketError) { if (readList != null) { ret += readList.Count; } if (writeList != null) { ret += writeList.Count; } if (exceptList != null) { ret += exceptList.Count; } } return(ret); }