VirtualBox

Changeset 53487 in vbox


Ignore:
Timestamp:
Dec 9, 2014 12:34:02 PM (10 years ago)
Author:
vboxsync
Message:

Split rtSocketBindRawAddr from rtSocketBind.

Location:
trunk/src/VBox/Runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/include/internal/socket.h

    r44529 r53487  
    5656int rtSocketCreate(PRTSOCKET phSocket, int iDomain, int iType, int iProtocol);
    5757int rtSocketBind(RTSOCKET hSocket, PCRTNETADDR pAddr);
     58int rtSocketBindRawAddr(RTSOCKET hSocket, void const *pvAddr, size_t cbAddr);
    5859int rtSocketListen(RTSOCKET hSocket, int cMaxPending);
    5960int rtSocketAccept(RTSOCKET hSocket, PRTSOCKET phClient, struct sockaddr *pAddr, size_t *pcbAddr);
  • trunk/src/VBox/Runtime/r3/socket.cpp

    r50457 r53487  
    15891589int rtSocketBind(RTSOCKET hSocket, PCRTNETADDR pAddr)
    15901590{
    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 
    15991591    RTSOCKADDRUNION u;
    16001592    int             cbAddr;
    16011593    int rc = rtSocketAddrFromNetAddr(pAddr, &u, sizeof(u), &cbAddr);
    16021594    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 */
     1609int 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();
    16071625
    16081626    rtSocketUnlock(pThis);
    16091627    return rc;
    16101628}
     1629
    16111630
    16121631
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette