1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| /* Option SO_REUSEADDR pour que le port specifie puisse etre reutilise */
/* Structure entree */
memset ((char *)&st_opt_req, 0, sizeof(st_opt_req)) ;
st_opt_req.opt.len = OPTLEN(sizeof(struct opthdr) + sizeof(long)) ;
st_opt_req.opt.maxlen = sizeof(tc_opt_req) ;
st_opt_req.opt.buf = tc_opt_req ;
st_opt_req.flags = T_NEGOTIATE ;
/* Structure rendue */
memset ((char *)&st_opt_ret, 0, sizeof(st_opt_ret)) ;
st_opt_ret.opt.len = 0 ;
st_opt_ret.opt.maxlen = sizeof(tc_opt_ret) ;
st_opt_ret.opt.buf = tc_opt_ret ;
st_opt_ret.flags = 0 ;
/* Option demandee */
l_opt = 1 ;
pst_sockopt = (struct opthdr *)tc_opt_req ;
pst_sockopt->level = SOL_SOCKET ;
pst_sockopt->name = SO_REUSEADDR ;
pst_sockopt->len = OPTLEN(sizeof(long)) ;
memcpy((char *)&pst_sockopt[1], (char *)&l_opt, pst_sockopt->len) ;
i_cr_tli = t_optmgmt(tfd, &st_opt_req, &st_opt_ret) ;
if (i_cr_tli < 0) /* C'est le cas ! */
{
/* Erreur */
tli_close (pst_etat_stream->fd) ;
pst_etat_stream->etat = CP_CNX_EN_ERREUR ;
pst_etat_stream->fd = -1 ;
i_cr = NOK ;
msg_ano (MACH, C_TLI_MESS_TLI, 188, (long) t_errno, (long) errno, (long) 0, (long) 0) ;
goto fin ;
}
else
{
i_cr = OK ;
pst_etat_stream->etat = CP_CNX_SEL ;
} |
Partager