diff --git a/Connector_RTMP/main.cpp b/Connector_RTMP/main.cpp index 4882dfcb..e6265733 100644 --- a/Connector_RTMP/main.cpp +++ b/Connector_RTMP/main.cpp @@ -50,7 +50,7 @@ int Connector_RTMP::Connector_RTMP(DDV::Socket conn){ //first timestamp set RTMPStream::firsttime = RTMPStream::getNowMS(); - while (RTMPStream::handshake_in.size() < 1537){ + while (Socket.connected() && (RTMPStream::handshake_in.size() < 1537)){ Socket.read(RTMPStream::handshake_in); } RTMPStream::rec_cnt += 1537; diff --git a/util/ddv_socket.cpp b/util/ddv_socket.cpp index 3b3567ac..c54cee42 100644 --- a/util/ddv_socket.cpp +++ b/util/ddv_socket.cpp @@ -106,21 +106,16 @@ bool DDV::Socket::connected(){ /// \returns True if the whole write was succesfull, false otherwise. bool DDV::Socket::write(const void * buffer, int len){ int sofar = 0; - Blocking = false; + if (sock < 0){return false;} while (sofar != len){ int r = send(sock, (char*)buffer + sofar, len-sofar, 0); if (r <= 0){ - switch (errno){ - case EWOULDBLOCK: Blocking = true; break; - default: - Error = true; - #if DEBUG >= 2 - fprintf(stderr, "Could not write data! Error: %s\n", strerror(errno)); - #endif - close(); - return false; - break; - } + Error = true; + #if DEBUG >= 2 + fprintf(stderr, "Could not write data! Error: %s\n", strerror(errno)); + #endif + close(); + return false; }else{ sofar += r; } @@ -137,21 +132,16 @@ bool DDV::Socket::write(const void * buffer, int len){ /// \returns True if the whole read was succesfull, false otherwise. bool DDV::Socket::read(void * buffer, int len){ int sofar = 0; - Blocking = false; + if (sock < 0){return false;} while (sofar != len){ int r = recv(sock, (char*)buffer + sofar, len-sofar, 0); if (r <= 0){ - switch (errno){ - case EWOULDBLOCK: Blocking = true; break; - default: - Error = true; - #if DEBUG >= 2 - fprintf(stderr, "Could not read data! Error: %s\n", strerror(errno)); - #endif - close(); - return false; - break; - } + Error = true; + #if DEBUG >= 2 + fprintf(stderr, "Could not read data! Error: %s\n", strerror(errno)); + #endif + close(); + return false; }else{ sofar += r; }