VirtualBox

Changeset 27504 in vbox for trunk/src/VBox/Runtime/r3


Ignore:
Timestamp:
Mar 18, 2010 9:06:06 PM (15 years ago)
Author:
vboxsync
Message:

socket.cpp,tcp.cpp: Windows build fixes.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/socket.cpp

    r27503 r27504  
    3434*******************************************************************************/
    3535#ifdef RT_OS_WINDOWS
    36 # include <winsock.h>
     36//# include <winsock.h>
     37# include <winsock2.h>
    3738#else /* !RT_OS_WINDOWS */
    3839# include <errno.h>
     
    7475# define MSG_NOSIGNAL           0
    7576#endif
     77
     78/* Windows has different names for SHUT_XXX. */
    7679#ifndef SHUT_RDWR
    7780# ifdef SD_BOTH
     
    8891# endif
    8992#endif
     93#ifndef SHUT_RD
     94# ifdef SD_RECEIVE
     95#  define SHUT_RD               SD_RECEIVE
     96# else
     97#  define SHUT_RD               0
     98# endif
     99#endif
    90100
    91101/* fixup backlevel OSes. */
     
    117127    SOCKET              hNative;
    118128    /** The event semaphore we've associated with the socket handle.
    119      * This is INVALID_HANDLE_VALUE if not done. */
     129     * This is WSA_INVALID_EVENT if not done. */
    120130    WSAEVENT            hEvent;
    121131    /** The pollset currently polling this socket.  This is NIL if no one is
     
    252262    pThis->hNative      = hNative;
    253263#ifdef RT_OS_WINDOWS
    254     pThis->hEvent       = INVALID_HANDLE_VALUE;
    255     pThis->hPollSet     = 0;
     264    pThis->hEvent       = WSA_INVALID_EVENT;
     265    pThis->hPollSet     = NIL_RTPOLLSET;
    256266    pThis->fPollEvts    = 0;
    257267#endif
     
    318328    int rc = VINF_SUCCESS;
    319329#ifdef RT_OS_WINDOWS
    320     if (pThis->hEvent == INVALID_HANDLE_VALUE)
    321     {
    322         CloseHandle(pThis->hEvent);
    323         pThis->hEvent = INVALID_HANDLE_VALUE;
    324     }
    325 
    326     if (pThis->hNative != INVALID_HANDLE_VALUE)
     330    if (pThis->hEvent == WSA_INVALID_EVENT)
     331    {
     332        WSACloseEvent(pThis->hEvent);
     333        pThis->hEvent = WSA_INVALID_EVENT;
     334    }
     335
     336    if (pThis->hNative != INVALID_SOCKET)
    327337    {
    328338        rc = closesocket(pThis->hNative);
     
    334344            AssertMsgFailed(("\"%s\": closesocket(%p) -> %Rrc\n", pThis->hNative, rc));
    335345        }
    336         pThis->hNative = INVALID_HANDLE_VALUE;
     346        pThis->hNative = INVALID_SOCKET;
    337347    }
    338348
     
    371381    int rc = VINF_SUCCESS;
    372382#ifdef RT_OS_WINDOWS
    373     if (!SetHandleInformation(pThis->hNative, HANDLE_FLAG_INHERIT, fInheritable ? HANDLE_FLAG_INHERIT : 0))
     383    if (!SetHandleInformation((HANDLE)pThis->hNative, HANDLE_FLAG_INHERIT, fInheritable ? HANDLE_FLAG_INHERIT : 0))
    374384        rc = RTErrConvertFromWin32(GetLastError());
    375385#else
  • trunk/src/VBox/Runtime/r3/tcp.cpp

    r27503 r27504  
    3434*******************************************************************************/
    3535#ifdef RT_OS_WINDOWS
    36 # include <winsock.h>
     36# include <winsock2.h>
    3737#else /* !RT_OS_WINDOWS */
    3838# include <errno.h>
     
    103103*   Structures and Typedefs                                                    *
    104104*******************************************************************************/
    105 /**
    106  * Socket handle data.
    107  *
    108  * This is mainly required for implementing RTPollSet on Windows.
    109  */
    110 typedef struct RTSOCKETINT
    111 {
    112     /** Magic number (RTTCPSOCKET_MAGIC). */
    113     uint32_t            u32Magic;
    114     /** Usage count.  This is used to prevent two threads from accessing the
    115      *  handle concurrently. */
    116     uint32_t volatile   cUsers;
    117 #ifdef RT_OS_WINDOWS
    118     /** The native socket handle. */
    119     SOCKET              hNative;
    120     /** The event semaphore we've associated with the socket handle.
    121      * This is INVALID_HANDLE_VALUE if not done. */
    122     WSAEVENT            hEvent;
    123     /** The pollset currently polling this socket.  This is NIL if no one is
    124      * polling. */
    125     RTPOLLSET           hPollSet;
    126     /** The events we're polling for. */
    127     uint32_t            fPollEvts;
    128 #else
    129     /** The native socket handle. */
    130     int                 hNative;
    131 #endif
    132 } RTSOCKETINT;
    133 
    134 
    135 /**
    136  * Address union used internally for things like getpeername and getsockname.
    137  */
    138 typedef union RTSOCKADDRUNION
    139 {
    140     struct sockaddr     Addr;
    141     struct sockaddr_in  Ipv4;
    142 #ifdef IPRT_WITH_TCPIP_V6
    143     struct sockaddr_in6 Ipv6;
    144 #endif
    145 } RTSOCKADDRUNION;
    146 
    147 
    148 
    149105/**
    150106 * TCP Server state.
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