- Timestamp:
- Jun 18, 2010 11:35:06 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/socket.cpp
r30275 r30306 596 596 { 597 597 #ifdef RT_OS_WINDOWS 598 # if 0 /* WSASendMsg is Vista+, so not an option */599 598 AssertCompileSize(WSABUF, sizeof(RTSGSEG)); 600 599 AssertCompileMemberSize(WSABUF, buf, RT_SIZEOFMEMB(RTSGSEG, pvSeg)); 601 600 AssertCompileMemberSize(WSABUF, len, RT_SIZEOFMEMB(RTSGSEG, cbSeg)); 602 601 603 LPWSABUF *paMsg = (LPWSABUF)RTMemTmpAllocZ(pSgBuf->cSeg * sizeof(WSABUF));602 LPWSABUF paMsg = (LPWSABUF)RTMemTmpAllocZ(pSgBuf->cSeg * sizeof(WSABUF)); 604 603 AssertPtrBreakStmt(paMsg, rc = VERR_NO_MEMORY); 605 604 for (unsigned i = 0; i < pSgBuf->cSeg; i++) 606 605 { 607 paMsg[i].buf = pSgBuf->pcaSeg[i].pvSeg;606 paMsg[i].buf = (char *)pSgBuf->pcaSeg[i].pvSeg; 608 607 paMsg[i].len = pSgBuf->pcaSeg[i].cbSeg; 609 608 } 610 609 611 WSAMSG msgHdr;612 610 DWORD dwSent; 613 memset(&msgHdr, '\0', sizeof(msgHdr)); 614 msgHdr.lpBuffers = paMsg; 615 msgHdr.dwBufferCount = pSgBuf->cSeg; 616 int hrc = WSASendMsg(pThis->hNative, &msgHdr, MSG_NOSIGNAL, &dwSent, 617 NULL, NULL); 611 int hrc = WSASend(pThis->hNative, paMsg, pSgBuf->cSeg, &dwSent, 612 MSG_NOSIGNAL, NULL, NULL); 618 613 ssize_t cbWritten; 619 614 if (!hrc) … … 624 619 else 625 620 cbWritten = -1; 626 RTMemTmpFree(paMsg);627 # else /* 1 */628 /* Portable but inefficient: copy everything to a single buffer and629 * use send(). Annoying that WSASendMsg() is so "new". */630 int cbBuf = 0;631 for (unsigned i = 0; i < pSgBuf->cSeg; i++)632 {633 cbBuf += (int)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 += (int)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 */649 621 #else 650 622 AssertCompileSize(struct iovec, sizeof(RTSGSEG)); … … 665 637 msgHdr.msg_iovlen = pSgBuf->cSeg; 666 638 ssize_t cbWritten = sendmsg(pThis->hNative, &msgHdr, MSG_NOSIGNAL); 639 #endif 640 667 641 RTMemTmpFree(paMsg); 668 #endif669 670 642 if (RT_LIKELY(cbWritten >= 0)) 671 643 rc = VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.