在librtmp的RTMP_Connect0( )中加入了send超时设置,如下添加蓝色部分代码,并重新编译librtmp库:
/* set timeout */
{
struct timeval timeout;
timeout.tv_sec = 5;
timeout.tv_usec = 0;
SET_RCVTIMEO(tv, r->Link.timeout);
if (setsockopt(r->m_sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)))
{
RTMP_Log(RTMP_LOGERROR, "%s, Setting socket timeout to %ds failed!", __FUNCTION__, r->Link.timeout);
}
if(setsockopt(r->m_sb.sb_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof(timeout)) == -1)
{
RTMP_Log(RTMP_LOGERROR, "%s, Setting socket timeout to %ds failed!", __FUNCTION__, timeout.tv_sec);
}
else
{
RTMP_Log(RTMP_LOGDEBUG, "%s, Setting socket timeout to %ds success!", __FUNCTION__, timeout.tv_sec);
}
}