diff --git a/AUTHORS.txt b/AUTHORS.txt index d036b8d202..28b4c85266 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -26,4 +26,5 @@ CONTRIBUTORS ordered by first contribution. * lovecat "Bug fixed" * panda1986<542638787@qq.com> "Bug fixed" * YueHonghui "Bug fixed" +* JuntaoLiu "Bug fixed" diff --git a/trunk/src/app/srs_app_listener.cpp b/trunk/src/app/srs_app_listener.cpp index d2d853b8b7..7516a79ca9 100755 --- a/trunk/src/app/srs_app_listener.cpp +++ b/trunk/src/app/srs_app_listener.cpp @@ -223,6 +223,16 @@ int SrsTcpListener::listen() } srs_verbose("setsockopt reuse-addr success. port=%d, fd=%d", port, _fd); +#ifdef SO_KEEPALIVE + int tcp_keepalive = 1; + if (setsockopt(_fd, SOL_SOCKET, SO_KEEPALIVE, &tcp_keepalive, sizeof(int)) == -1) { + ret = ERROR_SOCKET_SETKEEPALIVE; + srs_error("setsockopt SO_KEEPALIVE[%d]error. port=%d, ret=%d", tcp_keepalive, port, ret); + return ret; + } + srs_verbose("setsockopt SO_KEEPALIVE[%d]success. port=%d", tcp_keepalive, port); +#endif + sockaddr_in addr; addr.sin_family = AF_INET; addr.sin_port = htons(port); diff --git a/trunk/src/kernel/srs_kernel_error.hpp b/trunk/src/kernel/srs_kernel_error.hpp index aa2cddfc69..cdc561a1e4 100755 --- a/trunk/src/kernel/srs_kernel_error.hpp +++ b/trunk/src/kernel/srs_kernel_error.hpp @@ -98,6 +98,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define ERROR_SYSTEM_CREATE_DIR 1057 #define ERROR_SYSTEM_KILL 1058 #define ERROR_SYSTEM_DNS_RESOLVE 1059 +#define ERROR_SOCKET_SETKEEPALIVE 1060 /////////////////////////////////////////////////////// // RTMP protocol error.