Changeset 32276 in vbox for trunk/src/VBox
- Timestamp:
- Sep 7, 2010 11:33:52 AM (14 years ago)
- Location:
- trunk/src/VBox/Runtime/r3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/socket.cpp
r32134 r32276 29 29 * Header Files * 30 30 *******************************************************************************/ 31 #define LOG_ENABLED 31 32 #ifdef RT_OS_WINDOWS 32 33 # include <winsock2.h> … … 293 294 * @param ppSocket Where to return the IPRT socket handle. 294 295 * @param hNative The native handle. 296 295 297 */ 296 298 int rtSocketCreateForNative(RTSOCKETINT **ppSocket, RTSOCKETNATIVE hNative) … … 980 982 981 983 984 RTDECL(int) RTSocketSelectOneEx(RTSOCKET hSocket, uint32_t fEvents, uint32_t *pfEvents, 985 RTMSINTERVAL cMillies) 986 { 987 /* 988 * Validate input. 989 */ 990 RTSOCKETINT *pThis = hSocket; 991 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 992 AssertReturn(pThis->u32Magic == RTSOCKET_MAGIC, VERR_INVALID_HANDLE); 993 AssertPtrReturn(pfEvents, VERR_INVALID_PARAMETER); 994 AssertReturn(!(fEvents & ~RTSOCKET_EVT_VALID_MASK), VERR_INVALID_PARAMETER); 995 AssertReturn(RTMemPoolRefCount(pThis) >= (pThis->cUsers ? 2U : 1U), VERR_CALLER_NO_REFERENCE); 996 997 *pfEvents = 0; 998 999 /* 1000 * Set up the file descriptor sets and do the select. 1001 */ 1002 fd_set fdsetR; 1003 fd_set fdsetW; 1004 fd_set fdsetE; 1005 FD_ZERO(&fdsetR); 1006 FD_ZERO(&fdsetW); 1007 FD_ZERO(&fdsetE); 1008 1009 if (fEvents & RTSOCKET_EVT_READ) 1010 FD_SET(pThis->hNative, &fdsetR); 1011 if (fEvents & RTSOCKET_EVT_WRITE) 1012 FD_SET(pThis->hNative, &fdsetW); 1013 if (fEvents & RTSOCKET_EVT_ERROR) 1014 FD_SET(pThis->hNative, &fdsetE); 1015 1016 int rc; 1017 if (cMillies == RT_INDEFINITE_WAIT) 1018 rc = select(pThis->hNative + 1, &fdsetR, &fdsetW, &fdsetE, NULL); 1019 else 1020 { 1021 struct timeval timeout; 1022 timeout.tv_sec = cMillies / 1000; 1023 timeout.tv_usec = (cMillies % 1000) * 1000; 1024 rc = select(pThis->hNative + 1, &fdsetR, &fdsetW, &fdsetE, &timeout); 1025 } 1026 if (rc > 0) 1027 { 1028 if (FD_ISSET(pThis->hNative, &fdsetR)) 1029 *pfEvents |= RTSOCKET_EVT_READ; 1030 if (FD_ISSET(pThis->hNative, &fdsetW)) 1031 *pfEvents |= RTSOCKET_EVT_WRITE; 1032 if (FD_ISSET(pThis->hNative, &fdsetE)) 1033 *pfEvents |= RTSOCKET_EVT_ERROR; 1034 1035 rc = VINF_SUCCESS; 1036 } 1037 else if (rc == 0) 1038 rc = VERR_TIMEOUT; 1039 else 1040 rc = rtSocketError(); 1041 1042 return rc; 1043 } 1044 1045 982 1046 RTDECL(int) RTSocketShutdown(RTSOCKET hSocket, bool fRead, bool fWrite) 983 1047 { … … 1434 1498 if (RT_FAILURE(rc)) 1435 1499 { 1436 /** @todo */ 1500 WSAResetEvent(pThis->hEvent); 1501 fd_set fdsetR; 1502 fd_set fdsetW; 1503 FD_ZERO(&fdsetR); 1504 FD_ZERO(&fdsetW); 1505 FD_SET(pThis->hNative, &fdsetR); 1506 FD_SET(pThis->hNative, &fdsetW); 1507 1508 fd_set fdsetE = fdsetR; 1509 1510 struct timeval timeout; 1511 timeout.tv_sec = 0; 1512 timeout.tv_usec = 0; 1513 rc = select(pThis->hNative + 1, &fdsetR, &fdsetW, &fdsetE, &timeout); 1514 if (rc > 0) 1515 { 1516 rc = VINF_SUCCESS; 1517 if (FD_ISSET(pThis->hNative, &fdsetR)) 1518 fRetEvents |= RTPOLL_EVT_READ; 1519 if (FD_ISSET(pThis->hNative, &fdsetW)) 1520 fRetEvents |= RTPOLL_EVT_WRITE; 1521 if (FD_ISSET(pThis->hNative, &fdsetE)) 1522 fRetEvents |= RTPOLL_EVT_ERROR; 1523 } 1437 1524 } 1438 1525 -
trunk/src/VBox/Runtime/r3/tcp.cpp
r31103 r32276 1003 1003 1004 1004 1005 RTR3DECL(int) RTTcpSelectOneEx(RTSOCKET Sock, uint32_t fEvents, uint32_t *pfEvents, 1006 RTMSINTERVAL cMillies) 1007 { 1008 return RTSocketSelectOneEx(Sock, fEvents, pfEvents, cMillies); 1009 } 1010 1011 1005 1012 RTR3DECL(int) RTTcpGetLocalAddress(RTSOCKET Sock, PRTNETADDR pAddr) 1006 1013 {
Note:
See TracChangeset
for help on using the changeset viewer.