首页 > 代码库 > socket reuse

socket reuse

    int k   =   1;
    if( SUCCESS != m_socketServer.setSockOptSocket( SO_REUSEADDR, (char*)&k, sizeof(k), SOL_SOCKET ) ) {
        PRINT("setSockOptSocket SO_REUSEADDR error\n");
    }

    linger  m_sLinger;
    m_sLinger.l_onoff   =   1;
    m_sLinger.l_linger  =   0;
    if( SUCCESS != m_socketServer.setSockOptSocket( SO_LINGER, (char*)&m_sLinger, sizeof(m_sLinger), SOL_SOCKET ) ) {
        PRINT("setSockOptSocket SO_LINGER error\n");
    }

socket reuse