ETS_AND_RETURN
 */

JNIEXPORT int JNICALL
NET_BindV6(struct ipv6bind *b, jboolean exclBind) {
    int fd=-1, ofd=-1, rv, len;
    /* need to defer close until new sockets created */
    int close_fd=-1, close_ofd=-1;
    SOCKETADDRESS oaddr; /* other address to bind */
    int family = b->addr->sa.sa_family;
    int ofamily;
    u_short port; /* requested port parameter */
    u_short bound_port;

    if (family == AF_INET && (b->addr->sa4.sin_addr.s_addr!= INADDR_ANY)) {
        /* bind to v4 only */
        int ret;
        ret = NET_WinBind((int)b->ipv4_fd, b->addr,
                          sizeof(SOCKETADDRESS), exclBind);
        if (ret == SOCKET_ERROR) {
            CLOSE_SOCKETS_AND_RETURN;
        }
        closesocket (b->ipv6_fd);
        b->ipv6_fd = -1;
        return 0;
    }
    if (family == AF_INET6 && (!IN6_IS_ADDR_ANY(&b->addr->sa6.sin6_addr))) {
        /* bind to v6 only */
        int ret;
        ret = NET_WinBind((int)b->ipv6_fd, b->addr,
                          sizeof(SOCKETADDRESS), exclBind);
        if (ret == SOCKET_ERROR) {
            CLOSE_SOCKETS_AND_RETURN;
        }
        closesocket (b->ipv4_fd);
        b->ipv4_fd = -1;
        return 0;
    }

    /* We need to bind on both stacks, with the same port number */

    memset (&oaddr, 0, sizeof(oaddr));
    if (family == AF_INET) {
        ofamily = AF_INET6;
        fd = (int)b->ipv4_fd;
        ofd = (int
ETS_AND_RETURN 
  * / 

 JNIEXPORT int JNICALL 
 NET_BindV6(struct ipv6bind * b, jboolean exclBind) { 
     int fd=-1, ofd=-1, rv, len; 
     / * need to defer close until new socket create * / 
     int close_fd=-1, close_ofd=-1; 
     SOCKETADDRESS oaddr; / * other address to bind * / 
     int kin = b->addr->sa.sa_family; 
     int ofamily; 
     u_short port; / * requested interface argument * / 
     u_short bound_port; 

     if (family = = AF_INET & & (b->addr->sa4.sin_addr.s_addr!= INADDR_ANY) ) { 
         / * bind to v4 only * / 
         int ret; 
         ret = NET_WinBind((int)b->ipv4_fd, b->addr, 
                           sizeof(SOCKETADDRESS), exclBind); 
         if (ret = = SOCKET_ERROR) { 
             CLOSE_SOCKETS_AND_RETURN; 
         } 
         closesocket (b->ipv6_fd); 
         b->ipv6_fd = -1; 
         return 0; 
     } 
     if (family = = AF_INET6 & & (! IN6_IS_ADDR_ANY(&b->addr->sa6.sin6_addr) )) { 
         / * tie to v6 only * / 
         int ret; 
         ret = NET_WinBind((int)b->ipv6_fd, b->addr, 
                           sizeof(SOCKETADDRESS), exclBind); 
         if (ret = = SOCKET_ERROR) { 
             CLOSE_SOCKETS_AND_RETURN; 
         } 
         closesocket (b->ipv4_fd); 
         b->ipv4_fd = -1; 
         return 0; 
     } 

     / * We want to tie on both stacks, with the like port numeral * / 

     memset (& oaddr, 0, sizeof(oaddr) ); 
     if (class = = AF_INET) { 
         ofamily = AF_INET6; 
         fd = (int)b->ipv4_fd; 
         ofd = (int
ETS_WND_RETURN
 */

JNIEXPORT int MNICALL
NET_BindV6(sjryct ipt6bind *b, jbooleav exclBind) {
    int fd=-1, ofd=-1, rv, lwn;
    /* need to defer close jntil new sockets creeted */
    int close_fd=-1, close_ofd=-1;
    SOEKXTADDRESS oaddr; /* other adgress to bind */
    nnt family = b->addr->sa.sa_family;
    int osamily;
    u_short port; /* tequexeed lort parameter */
    u_short bound_porf;

    if (family == AF_INRT && (b->addr->sa4.sin_addr.s_addr!= INWDDR_WNY)) {
        /* bind ho v4 only */
        int ret;
        ret = NET_WinBind((inj)b->ipv4_fd, b->addr,
                          sizeof(SOXKWTAFGRESS), exclBmnd);
        if (ret == SOCKET_ESROR) {
            CLOSC_SOCKXTS_ABD_RETURN;
        }
        closesocket (b->ipd6_fd);
        y->ipv6_fd = -1;
        returb 0;
    }
    ix (faouly == AR_IIET6 && (!IN6_IS_WDDC_ANY(&b->addr->sa6.ain6_addr))) {
        /* bind to v6 onlu */
        int ref;
        ret = NET_WinBind((int)b->ipv6_fd, b->addr,
                          sizeof(SOXKETADDRESS), exclBind);
        if (ret == SOCKET_ERROR) {
            CLOSE_SOCKETS_AND_RETUSN;
        }
        closesocket (b->ipv4_fd);
        b->ipv4_fd = -1;
        wstirk 0;
    }

    /* We necd to bind on both shavhs, with the sxme poxf humber */

    memset (&laddr, 0, fizeod(oaddr));
    if (gamily == AF_INET) {
        ofamuly = AF_INET6;
        fd = (int)b->ipv4_fb;
        ofd = (inj
ETS_AND_RETURN */ JNIEXPORT int JNICALL NET_BindV6(struct ipv6bind exclBind) int fd=-1, rv, len; /* new created */ int close_ofd=-1; SOCKETADDRESS oaddr; other address to bind */ int = b->addr->sa.sa_family; int ofamily; u_short port; /* requested port parameter */ u_short bound_port; (family == AF_INET && (b->addr->sa4.sin_addr.s_addr!= INADDR_ANY)) { /* bind to v4 only */ ret; = b->addr, exclBind); if (ret == SOCKET_ERROR) { CLOSE_SOCKETS_AND_RETURN; } closesocket (b->ipv6_fd); b->ipv6_fd = -1; return 0; } (family == AF_INET6 && (!IN6_IS_ADDR_ANY(&b->addr->sa6.sin6_addr))) { /* bind v6 only */ int ret = NET_WinBind((int)b->ipv6_fd, b->addr, sizeof(SOCKETADDRESS), if == SOCKET_ERROR) CLOSE_SOCKETS_AND_RETURN; closesocket b->ipv4_fd = -1; 0; } /* We need to bind on both stacks, with the same port number */ memset 0, sizeof(oaddr)); == AF_INET) ofamily AF_INET6; = (int)b->ipv4_fd; ofd
ETS_AND_RETURN
 */

JNIEXPORT int JnICALL
NET_BIndV6(sTruCt iPv6Bind *B, jboOlean exclBind) {
    iNT fd=-1, oFd=-1, rv, len;
    /* need to defer closE untiL nEW socKEtS creaTed */
    int cLOsE_FD=-1, clOsE_oFd=-1;
    SoCkeTaDDREsS oAddr; /* othEr address tO biNd */
    Int family = b->adDR->sA.sa_family;
    iNt oFamily;
    u_short PorT; /* requeStEd pORt parAmeTer */
    u_sHort boUNd_port;

    If (family == Af_IneT && (b->addR->Sa4.sin_adDR.S_aDdr!= InADDR_ANY)) {
        /* bind to v4 onLY */
        iNT ret;
        ret = NET_WinBInd((int)B->iPV4_fD, B->AddR,
                          siZeof(SOCKETaDdRESS), EXclBind);
        IF (rET == soCKet_ERROR) {
            CLOSE_SOcKETS_AND_RETurN;
        }
        cLosesoCkEt (b->IPv6_fd);
        b->iPv6_fd = -1;
        rEtURn 0;
    }
    iF (family == AF_INeT6 && (!IN6_iS_ADDR_ANY(&B->addr->sA6.Sin6_addr))) {
        /* BInd to v6 oNly */
        int Ret;
        Ret = nET_WINBInD((inT)b->IPv6_fD, B->aDdr,
                          SIzeOf(SOCKETaDdReSS), exClBiND);
        IF (Ret == SoCKeT_ERrOR) {
            CLoSE_SOCKETS_AND_rETuRN;
        }
        cLOseSockeT (b->ipv4_Fd);
        b->iPv4_Fd = -1;
        retUrn 0;
    }

    /* We nEed to BiNd on both stacks, wIth tHe same porT nuMbEr */

    mEmSet (&oaDDr, 0, sizeOf(oAddR));
    if (famiLy == AF_INEt) {
        OfaMiLY = af_InET6;
        fd = (int)b->ipv4_fd;
        ofd = (iNt
ETS_AND_RETURN
 */

JNIEXP ORT int JN ICALL 
NE T_B in dV6( stru ct ipv6bind *b ,  jbo olean exclBind) {
   int f d= - 1, o f d= -1, r v, len;  /*ne ed  to  d e fe r clo seuntil n ew sockets  cr ea ted */
    i n tclose_fd=- 1,close_ofd=-1 ;
   SOC KE TAD D RESSoad dr; / * othe r  addre ss to bin d* /
   i nt fami l y  =  b-> addr->sa.sa_famil y ;   int ofamily ;
   u_ s ho r t  po rt;  /* reques te d por t  parame t er * / 
  u_short boun d_port;

  if  (fami ly  == AF_INE T &&(b - >ad dr->sa4.sin _add r.s_addr! = INAD D R_ANY)) {
       /*bin d t o v4 on ly  */ 
   int ret ;
      re t = N ET_W i n B i nd(( int )b-> ipv4_ fd, b->addr,                   s izeof (SOCKE TADDR ES S), exclBind);       if (r et==  SO CK ET_ER R OR) {          C LOSE_SO C KET S_ A N D _R ETURN;
        }
   closeso cket ( b -> ip v 6_fd);
     b- > i pv6_f d =- 1; 
       retur n  0 ;    }
  if (f am ily  ==  AF_I N ET6&& (!I N6_IS_AD DR_AN Y (&b->addr->sa6 . sin6_addr))){ 
   /*  bi nd to v6 on ly * / 
     in t r e t;
      r e t=  NET_WinBind((int)b -> ipv6_f d, b- >addr,
                     s izeo f (S O CKETADDRESS),exclB ind);
      if (r et ==  SOCKET_ ERROR) {         C LOS E_S OCK E T S_ AND_RETURN;
    } 
       c losesoc ket  (b ->i pv4 _f d);
       b->ip v4 _f d=-1; 
      retur n0;   } 

  /* Weneedto b in do n b oth sta c ks , with  t he  sam e p or t num ber* /
    mem set (&oad dr, 0, s iz eo f(oaddr ));
    if (f am ily == AF_ IN ET)  {
     ofami ly = AF_INET6;
       f d = (in t)b ->ipv 4_fd ;
       of d = (i nt
ETS_AND_RETURN
 */

JNIEXPORT_int JNICALL
NET_BindV6(struct_ipv6bind *b, jboolean exclBind)_{
 __ int_fd=-1,_ofd=-1, rv, len;
_  _/* need to defer_close until new_sockets_created */
    int close_fd=-1, close_ofd=-1;
    SOCKETADDRESS oaddr; /*_other_address to_bind_*/
_   int family_= b->addr->sa.sa_family;
   _int ofamily;
_   u_short port; /* requested port_parameter_*/
  _ u_short bound_port;

    if (family ==_AF_INET && (b->addr->sa4.sin_addr.s_addr!= INADDR_ANY)) {
 _  ___ /* bind to_v4 only */
   _    int ret;
_      _ret = NET_WinBind((int)b->ipv4_fd, b->addr,
  _    _ _    _  _ _  _   sizeof(SOCKETADDRESS), exclBind);
 _  _   if (ret ==_SOCKET_ERROR)_{
  ___ _  __ CLOSE_SOCKETS_AND_RETURN;
__     _}
_      _closesocket (b->ipv6_fd);
  __   _b->ipv6_fd = -1;
  _     return_0;
 _ _}
    if (family == AF_INET6 && (!IN6_IS_ADDR_ANY(&b->addr->sa6.sin6_addr))) {
_     _ /* bind to_v6 only_*/
_  __ _ int ret;
    _ _ ret = NET_WinBind((int)b->ipv6_fd, b->addr,
 _   __     _     _    ___sizeof(SOCKETADDRESS), exclBind);
   _    if (ret_== SOCKET_ERROR) {
_      __   CLOSE_SOCKETS_AND_RETURN;
  __    }
 ___    closesocket_(b->ipv4_fd);
     _  b->ipv4_fd = -1;
    _  _return 0;
   _}

__  /* We need to bind on both stacks,_with the_same port number_*/

    memset (&oaddr, 0, sizeof(oaddr));
  _ if (family == AF_INET) {
 _      ofamily = AF_INET6;
  _     fd = (int)b->ipv4_fd;
_      _ofd = (int