Socket bugfix

This commit is contained in:
Thulinma 2011-04-18 15:09:31 +02:00
parent 7cb55a400a
commit ca1e60b461
2 changed files with 15 additions and 25 deletions

View file

@ -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;

View file

@ -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;
}