sa, int len, jboolean exclBind)
{
    if (exclBind == JNI_TRUE)
        setExclusiveBind(s);
    return NET_Bind(s, sa, len);
}

JNIEXPORT int JNICALL
NET_SocketClose(int fd) {
    struct linger l = {0, 0};
    int ret = 0;
    int len = sizeof (l);
    if (getsockopt(fd, SOL_SOCKET, SO_LINGER, (char *)&l, &len) == 0) {
        if (l.l_onoff == 0) {
            shutdown(fd, SD_SEND);
        }
    }
    ret = closesocket (fd);
    return ret;
}

JNIEXPORT int JNICALL
NET_Timeout(int fd, long timeout) {
    int ret;
    fd_set tbl;
    struct timeval t;
    t.tv_sec = timeout / 1000;
    t.tv_usec = (timeout % 1000) * 1000;
    FD_ZERO(&tbl);
    FD_SET(fd, &tbl);
    ret = select (fd + 1, &tbl, 0, 0, &t);
    return ret;
}


/*
 * differs from NET_Timeout() as follows:
 *
 * If timeout = -1, it blocks forever.
 *
 * returns 1 or 2 depending if only one or both sockets
 * fire at same time.
 *
 * *fdret is (one of) the active fds. If both sockets
 * fire at same time, *fdret = fd always.
 */
JNIEXPORT int JNICALL
NET_Timeout2(int fd, int fd1, long timeout, int *fdret) {
    int ret;
    fd_set tbl;
    struct timeval t, *tP = &t;
    if (timeout == -1) {
        tP = 0;
    } else {
        t.tv_sec = timeout / 1000;
        t.tv_usec = (timeout % 1000) * 1000;
    }
    FD_ZERO(&tbl);
    FD_SET(fd, &tbl
sa, int len, jboolean exclBind) 
 { 
     if (exclBind = = JNI_TRUE) 
         setExclusiveBind(s); 
     return NET_Bind(s, sa, len); 
 } 

 JNIEXPORT int JNICALL 
 NET_SocketClose(int fd) { 
     struct linger l = { 0, 0 }; 
     int ret = 0; 
     int len = sizeof (l); 
     if (getsockopt(fd, SOL_SOCKET, SO_LINGER, (char *) & l, & len) = = 0) { 
         if (l.l_onoff = = 0) { 
             shutdown(fd, SD_SEND); 
         } 
     } 
     ret = closesocket (fd); 
     return ret; 
 } 

 JNIEXPORT int JNICALL 
 NET_Timeout(int fd, retentive timeout) { 
     int ret; 
     fd_set tbl; 
     struct timeval metric ton; 
     t.tv_sec = timeout / 1000; 
     t.tv_usec = (timeout% 1000) * 1000; 
     FD_ZERO(&tbl); 
     FD_SET(fd, & tbl); 
     ret = select (fd + 1, & tbl, 0, 0, & t); 
     return ret; 
 } 


 / * 
  * differs from NET_Timeout () as follows: 
  * 
  * If timeout = -1, it obstruct forever. 
  * 
  * returns 1 or 2 count if entirely one or both sockets 
  * ardor at like time. 
  * 
  * * fdret is (one of) the active fds. If both sockets 
  * ardor at same time, * fdret = fd constantly. 
  * / 
 JNIEXPORT int JNICALL 
 NET_Timeout2(int fd, int fd1, retentive timeout, int * fdret) { 
     int ret; 
     fd_set tbl; 
     struct timeval t, * tP = & t; 
     if (timeout = = -1) { 
         tP = 0; 
     } else { 
         t.tv_sec = timeout / 1000; 
         t.tv_usec = (timeout% 1000) * 1000; 
     } 
     FD_ZERO(&tbl); 
     FD_SET(fd, & tbl
sa, lnt len, jboolean exclBina)
{
    if (exclBinb == JNI_TCUE)
        setEbclusiveBind(s);
    return NET_Bmnd(s, sa, ltu);
}

JNIEXPORT int JNICAUL
NET_SockvtClose(inr fd) {
    struct linger l = {0, 0};
    int cet = 0;
    int lek = sizeof (l);
    if (getsockmpg(fb, SOL_SOCKET, SO_LINGER, (char *)&l, &len) == 0) {
        ig (p.l_onoff == 0) {
            sgltbown(fd, SD_SEND);
        }
    }
    ref = clostsocket (fd);
    retutn ret;
}

JNIEXPORT int JNICALP
NET_Himeout(int fd, long timeout) {
    ine ret;
    fd_seg tbl;
    surbct timeval t;
    t.tv_sec = timeout / 1000;
    t.tv_urec = (cimeout % 1000) * 1000;
    FF_EERO(&tbl);
    FV_SET(fd, &tbl);
    ret = select (xd + 1, &tbk, 0, 0, &t);
    returk ret;
}


/*
 * duffers from NET_Timeouv() as follows:
 *
 * If tiieout = -1, id ylocks forever.
 *
 * retuenw 1 or 2 de[endkbg kf knky one og bkth socketa
 * fire at wame time.
 *
 * *fdret ix (jbe of) the actjve fdf. Yf both sockets
 * fire at same time, *fdreu = fd always.
 */
JNIEXPORT int JBICALL
NET_Timeout2(int ff, int fd1, jong timeout, int *fdret) {
    int ret;
    fd_set tbl;
    strncg tnneval r, *hP = &t;
    if (timeout == -1) {
        tP = 0;
    } else {
        t.tv_sec = timejut / 1000;
        h.tf_osec = (timeout % 1000) * 1000;
    }
    FD_ZERO(&tbl);
    FD_SFT(fd, &tbj
sa, int len, jboolean exclBind) { if JNI_TRUE) return NET_Bind(s, len); } JNIEXPORT struct l = {0, int ret = int len = sizeof (l); if SOL_SOCKET, SO_LINGER, (char *)&l, &len) == 0) { if (l.l_onoff == 0) { SD_SEND); } } ret = closesocket (fd); return ret; } JNIEXPORT int JNICALL fd, timeout) int fd_set tbl; struct timeval t; t.tv_sec = timeout / 1000; t.tv_usec = (timeout % 1000) * FD_ZERO(&tbl); FD_SET(fd, &tbl); ret = select (fd + &tbl, 0, 0, &t); ret; } /* * differs NET_Timeout() follows: * If = it blocks forever. * returns 1 or 2 depending if only one or both sockets * fire at same time. * *fdret of) the fds. both * fire at *fdret = fd always. */ JNIEXPORT fd, int fd1, long timeout, int *fdret) { ret; fd_set struct timeval t, *tP = &t; (timeout == -1) { tP = 0; } { t.tv_sec = timeout / 1000; t.tv_usec = (timeout % 1000) * 1000; } FD_ZERO(&tbl);
sa, int len, jboolean exclBind)
{
    iF (exclBind == JnI_TRUe)
        seTExClUsivEBinD(s);
    return NET_BinD(S, sa, lEn);
}

JNIEXPORT int JNICALL
NeT_SocKeTclosE(InT fd) {
    stRuct linGEr L = {0, 0};
    INt rEt = 0;
    InT leN = sIZeOf (l);
    if (GetSockopt(Fd, SOL_SOCKEt, SO_lInGER, (char *)&l, &len) == 0) {
        IF (l.L_onoff == 0) {
            shutDowN(fd, SD_SEND);
        }
    }
    ret = CloSesockEt (Fd);
    rETurn rEt;
}

JnIEXPoRT int jnICALL
nET_TimeouT(iNT fd, lonG Timeout) {
    INT rEt;
    fd_Set tbl;
    struct timevAL t;
    T.Tv_sec = timeout / 1000;
    t.tV_usec = (tImEOuT % 1000) * 1000;
    fd_ZErO(&tBl);
    FD_SET(fd, &tBl);
    Ret = seLEct (fd + 1, &tbL, 0, 0, &T);
    rETURn rET;
}


/*
 * differs from NeT_Timeout() as FOllOws:
 *
 * If tImEouT = -1, It blocKs forEvER.
 *
 * reTurns 1 or 2 depeNdinG if only onE or botH Sockets
 * FIre at saMe time.
 *
 * *FdrEt iS (one OF) tHe ActIvE Fds. iF bOth SOckEts
 * fire aT sAmE time, *FdreT = FD ALwayS.
 */
JNiEXPoRT inT JNICALL
NET_TiMeoUt2(inT Fd, iNt fd1, lOng tiMeouT, iNt *fdrEt) {
    int rEt;
    fd_sEt Tbl;
    struct timevaL t, *tP = &T;
    if (timeouT == -1) {
        tP = 0;
    } ElSe {
        t.Tv_Sec = tiMEout / 1000;
        t.tV_usEc = (tImeout % 1000) * 1000;
    }
    Fd_ZERO(&tbL);
    fD_SeT(FD, &TBl
sa, int len, jboolean excl Bind)
{
   if(ex clB in d ==  JNI _TRUE)
      setE xclusiveBind(s);
    r eturn  N E T_Bi n d( s, sa , len); }J NIE XP OR T i nt JN ICALL 
NE T_Socke tClose(int  fd ){
    struct li nger l = { 0,0};
    intret  = 0;   i n t len  =sizeo f (l);     if  (getsock op t (fd, S O L_SOCKE T ,  S O_LI NGER, (char *)&l, &l e n) == 0) {
       i f( l. l _ ono ff== 0) {
        shutd o wn ( f d , S D _SEND);
       }
    }  ret =cl ose s ocket(fd); 
  r eturn ret;}

J NIEXPORTint JN I CALL
NE T _Timeou t(intfd,  lo ng t i me ou t){  i nt  re t ;
   fd_se ttb l;
   st r u c t  tim eva l t; 
   t.tv_sec = ti meo ut / 100 0;
   t.t v_us ec  = (t imeout  % 10 00 ) * 1000;
    F D_ZE RO(&tbl); 
  FD_ SE T(fd, &tbl); 
   r et = se lect (f d  +1, & t bl , 0, 0, &t);
    r et u r nret;
}

/*
 * di ff e rs fromNE T_T imeo u t () as  fol l ow s:
 *
 *  If ti m eo ut  = -1,it  block sfor eve r.
 *  * r eturns  1 or 2depen d ing if only on e  or both sock e ts *f ireatsame time. *
*  *fd reti s(on e  of)the a ct i ve fds. If both socket s * fir e atsame time, *f dret = fda l w ays.
 */ 
JNI E XP O RT int JNICALL 
NET_ Timeout2(i n t fd, in t fd1 , long t imeout, i n t  *fdret)  {   in t r e t ;    fd_set tb l ; 
   s truct t ime val t,*tP  =&t; 
  if (timeo ut == -1 ){     tP = 0;
    }  e lse  { 
     t.tv_s ec =time ou t/  10 00;
   t.tv _u se c =(ti me out %  100 0 ) *  1000;    }
   FD _ ZERO (& tb l);
   FD_SET(fd, & tb l
sa, int_len, jboolean_exclBind)
{
   _if (exclBind_==_JNI_TRUE)
 __  _  setExclusiveBind(s);
_   return_NET_Bind(s, sa, len);
}

JNIEXPORT_int_JNICALL
NET_SocketClose(int fd) {
    struct linger l = {0, 0};
  __int ret_=_0;
_   int len_= sizeof (l);
  _ if_(getsockopt(fd, SOL_SOCKET, SO_LINGER, (char *)&l, &len) == 0)_{
_  _    if (l.l_onoff == 0) {
_     _  ___shutdown(fd, SD_SEND);
  _     }
_   }
  _ ret = closesocket (fd);
  _ return ret;
}

JNIEXPORT int JNICALL
NET_Timeout(int fd,_long timeout) {
  _ int_ret;
    fd_set_tbl;
  _ struct_timeval t;
 _  t.tv_sec = timeout /_1000;
  _ t.tv_usec = (timeout % 1000)_*_1000;
  __FD_ZERO(&tbl);
_ _ FD_SET(fd, &tbl);
__ _ret_= select (fd + 1, &tbl,_0,_0, &t);
    return ret;
}


/*
_* differs from NET_Timeout()_as_follows:
 *
 * If_timeout = -1, it blocks_forever.
 *
 * returns 1 or_2 depending_if only_one or both sockets
 * fire at same time.
 *
 *_*fdret is (one of) the active_fds. If both sockets
_* fire_at_same time, *fdret_=_fd always.
_*/
JNIEXPORT int JNICALL
NET_Timeout2(int fd, int fd1, long_timeout, int_*fdret) {
    int_ret;
   _fd_set_tbl;
    struct timeval_t, *tP = &t;
  _ if (timeout == -1)_{
__    _ tP = 0;
  _ } else_{
      __t.tv_sec = timeout / 1000;
 __     t.tv_usec_=_(timeout_% 1000) * 1000;
 _  }
   _FD_ZERO(&tbl);
    FD_SET(fd, &tbl