Changeset 53487 in vbox
- Timestamp:
- Dec 9, 2014 12:34:02 PM (10 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/include/internal/socket.h
r44529 r53487 56 56 int rtSocketCreate(PRTSOCKET phSocket, int iDomain, int iType, int iProtocol); 57 57 int rtSocketBind(RTSOCKET hSocket, PCRTNETADDR pAddr); 58 int rtSocketBindRawAddr(RTSOCKET hSocket, void const *pvAddr, size_t cbAddr); 58 59 int rtSocketListen(RTSOCKET hSocket, int cMaxPending); 59 60 int rtSocketAccept(RTSOCKET hSocket, PRTSOCKET phClient, struct sockaddr *pAddr, size_t *pcbAddr); -
trunk/src/VBox/Runtime/r3/socket.cpp
r50457 r53487 1589 1589 int rtSocketBind(RTSOCKET hSocket, PCRTNETADDR pAddr) 1590 1590 { 1591 /*1592 * Validate input.1593 */1594 RTSOCKETINT *pThis = hSocket;1595 AssertPtrReturn(pThis, VERR_INVALID_HANDLE);1596 AssertReturn(pThis->u32Magic == RTSOCKET_MAGIC, VERR_INVALID_HANDLE);1597 AssertReturn(rtSocketTryLock(pThis), VERR_CONCURRENT_ACCESS);1598 1599 1591 RTSOCKADDRUNION u; 1600 1592 int cbAddr; 1601 1593 int rc = rtSocketAddrFromNetAddr(pAddr, &u, sizeof(u), &cbAddr); 1602 1594 if (RT_SUCCESS(rc)) 1603 { 1604 if (bind(pThis->hNative, &u.Addr, cbAddr) != 0) 1605 rc = rtSocketError(); 1606 } 1595 rc = rtSocketBindRawAddr(hSocket, &u.Addr, cbAddr); 1596 return rc; 1597 } 1598 1599 1600 /** 1601 * Very thin wrapper around bind. 1602 * 1603 * @returns IPRT status code. 1604 * @param hSocket The socket handle. 1605 * @param pvAddr The address to bind to (struct sockaddr and 1606 * friends). 1607 * @param cbAddr The size of the address. 1608 */ 1609 int rtSocketBindRawAddr(RTSOCKET hSocket, void const *pvAddr, size_t cbAddr) 1610 { 1611 /* 1612 * Validate input. 1613 */ 1614 RTSOCKETINT *pThis = hSocket; 1615 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 1616 AssertReturn(pThis->u32Magic == RTSOCKET_MAGIC, VERR_INVALID_HANDLE); 1617 AssertPtrReturn(pvAddr, VERR_INVALID_POINTER); 1618 AssertReturn(rtSocketTryLock(pThis), VERR_CONCURRENT_ACCESS); 1619 1620 int rc; 1621 if (bind(pThis->hNative, (struct sockaddr const *)pvAddr, cbAddr) == 0) 1622 rc = VINF_SUCCESS; 1623 else 1624 rc = rtSocketError(); 1607 1625 1608 1626 rtSocketUnlock(pThis); 1609 1627 return rc; 1610 1628 } 1629 1611 1630 1612 1631
Note:
See TracChangeset
for help on using the changeset viewer.