winlin

for bug #88, add timeout for connect.

... ... @@ -38,15 +38,24 @@ int main(int argc, char** argv)
u_int32_t timestamp = 0;
char* data;
if (argc <= 1) {
printf("play stream on RTMP server\n"
"Usage: %s <rtmp_url>\n"
" rtmp_url RTMP stream url to play\n"
"For example:\n"
" %s rtmp://127.0.0.1:1935/live/livestream\n",
argv[0]);
int ret = 1;
exit(ret);
return ret;
}
rtmp = srs_rtmp_create(argv[1]);
printf("suck rtmp stream like rtmpdump\n");
printf("srs(simple-rtmp-server) client librtmp library.\n");
printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
if (argc > 1) {
rtmp = srs_rtmp_create(argv[1]);
} else {
rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream");
}
printf("rtmp url: %s\n", rtmp);
if (srs_simple_handshake(rtmp) != 0) {
printf("simple handshake failed.\n");
... ...
... ... @@ -324,7 +324,7 @@ int SrsEdgeIngester::connect_server()
addr.sin_port = htons(port);
addr.sin_addr.s_addr = inet_addr(ip.c_str());
if (st_connect(stfd, (const struct sockaddr*)&addr, sizeof(sockaddr_in), ST_UTIME_NO_TIMEOUT) == -1){
if (st_connect(stfd, (const struct sockaddr*)&addr, sizeof(sockaddr_in), SRS_EDGE_INGESTER_TIMEOUT_US) == -1){
ret = ERROR_ST_CONNECT;
srs_error("connect to server error. ip=%s, port=%d, ret=%d", ip.c_str(), port, ret);
return ret;
... ... @@ -605,7 +605,7 @@ int SrsEdgeForwarder::connect_server()
addr.sin_port = htons(port);
addr.sin_addr.s_addr = inet_addr(ip.c_str());
if (st_connect(stfd, (const struct sockaddr*)&addr, sizeof(sockaddr_in), ST_UTIME_NO_TIMEOUT) == -1){
if (st_connect(stfd, (const struct sockaddr*)&addr, sizeof(sockaddr_in), SRS_EDGE_FORWARDER_TIMEOUT_US) == -1){
ret = ERROR_ST_CONNECT;
srs_error("connect to server error. ip=%s, port=%d, ret=%d", ip.c_str(), port, ret);
return ret;
... ...
... ... @@ -298,7 +298,7 @@ int SrsForwarder::connect_server()
addr.sin_port = htons(port);
addr.sin_addr.s_addr = inet_addr(ip.c_str());
if (st_connect(stfd, (const struct sockaddr*)&addr, sizeof(sockaddr_in), ST_UTIME_NO_TIMEOUT) == -1){
if (st_connect(stfd, (const struct sockaddr*)&addr, sizeof(sockaddr_in), SRS_FORWARDER_SLEEP_US) == -1){
ret = ERROR_ST_CONNECT;
srs_error("connect to server error. ip=%s, port=%d, ret=%d", ip.c_str(), port, ret);
return ret;
... ...
... ... @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR "0"
#define VERSION_MINOR "9"
#define VERSION_REVISION "115"
#define VERSION_REVISION "116"
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
... ...