diff --git a/Connector_RTMP/main.cpp b/Connector_RTMP/main.cpp index 04c31ebf..8814d03c 100644 --- a/Connector_RTMP/main.cpp +++ b/Connector_RTMP/main.cpp @@ -48,7 +48,7 @@ int main(int argc, char ** argv){ int status; while (server_socket > 0){ waitpid((pid_t)-1, &status, WNOHANG); - CONN_fd = DDV_Accept(server_socket); + CONN_fd = DDV_Accept(server_socket, true); if (CONN_fd > 0){ pid_t myid = fork(); if (myid == 0){ diff --git a/util/ddv_socket.cpp b/util/ddv_socket.cpp index 23f2de8b..0c14a371 100644 --- a/util/ddv_socket.cpp +++ b/util/ddv_socket.cpp @@ -55,8 +55,14 @@ int DDV_Listen(int port){ } } -int DDV_Accept(int sock){ - return accept(sock, 0, 0); +int DDV_Accept(int sock, bool nonblock = false){ + int r = accept(sock, 0, 0); + if ((r > 0) && nonblock){ + int flags = fcntl(r, F_GETFL, 0); + flags |= O_NONBLOCK; + fcntl(r, F_SETFL, flags); + } + return r; } bool DDV_write(void * buffer, int todo, int sock){