- Timestamp:
- Jun 17, 2010 7:54:20 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/socket.cpp
r30270 r30272 596 596 { 597 597 #ifdef RT_OS_WINDOWS 598 # if 0 /* WSASendMsg is Vista+, so not an option */ 598 599 AssertCompileSize(WSABUF, sizeof(RTSGSEG)); 599 600 AssertCompileMemberSize(WSABUF, buf, RT_SIZEOFMEMB(RTSGSEG, pvSeg)); … … 623 624 else 624 625 cbWritten = -1; 626 RTMemTmpFree(paMsg); 627 # else /* 1 */ 628 /* Portable but inefficient: copy everything to a single buffer and 629 * use send(). Annoying that WSASendMsg() is so "new". */ 630 int cbBuf = 0; 631 for (unsigned i = 0; i < pSgBuf->cSeg; i++) 632 { 633 cbBuf += pSgBuf->pcaSeg[i].cbSeg 634 AssertBreakStmt(cbBuf, rc = VERR_BUFFER_OVERFLOW); 635 } 636 637 void *pBuf = RTMemTmpAlloc(cbBuf); 638 AssertPtrBreakStmt(pBuf, rc = VERR_NO_MEMORY); 639 char *p = (char *)pBuf; 640 for (unsigned i = 0; i < pSgBuf->cSeg; i++) 641 { 642 memcpy(p, pSgBuf->pcaSeg[i].pvSeg, pSgBuf->pcaSeg[i].cbSeg); 643 p += pSgBuf->pcaSeg[i].cbSeg; 644 } 645 646 ssize_t cbWritten = send(pThis->hNative, (const char *)pBuf, cbBuf, MSG_NOSIGNAL); 647 RTMemTmpFree(pBuf); 648 # endif /* 1 */ 625 649 #else 626 650 AssertCompileSize(struct iovec, sizeof(RTSGSEG)); … … 641 665 msgHdr.msg_iovlen = pSgBuf->cSeg; 642 666 ssize_t cbWritten = sendmsg(pThis->hNative, &msgHdr, MSG_NOSIGNAL); 643 #endif644 645 667 RTMemTmpFree(paMsg); 668 #endif 669 646 670 if (RT_LIKELY(cbWritten >= 0)) 647 671 rc = VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.