Fixed so that receiving socket has no buffer limit when reading in Linux. See ticket #101.
This commit is contained in:
parent
6f2ea98c5c
commit
e3587763ee
1 changed files with 10 additions and 4 deletions
|
@ -78,9 +78,9 @@ std::wstring Socket::read() {
|
||||||
std::wstring Socket::read(int timeout) {
|
std::wstring Socket::read(int timeout) {
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
char inbuf[BUFSIZE];
|
char inbuf[BUFSIZE];
|
||||||
memset(inbuf, '\0', sizeof(inbuf));
|
|
||||||
|
|
||||||
FD_SET(d->socket, &d->infds);
|
FD_SET(d->socket, &d->infds);
|
||||||
|
std::string msg;
|
||||||
while(isConnected()) {
|
while(isConnected()) {
|
||||||
tv.tv_sec = floor(timeout / 1000.0);
|
tv.tv_sec = floor(timeout / 1000.0);
|
||||||
tv.tv_usec = timeout % 1000;
|
tv.tv_usec = timeout % 1000;
|
||||||
|
@ -93,15 +93,21 @@ std::wstring Socket::read(int timeout) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int received = recv(d->socket, inbuf, BUFSIZE - 1, 0);
|
int received = BUFSIZE;
|
||||||
if (received <= 0) {
|
while(received >= (BUFSIZE - 1)){
|
||||||
|
memset(inbuf, '\0', sizeof(inbuf));
|
||||||
|
received = recv(d->socket, inbuf, BUFSIZE - 1, 0);
|
||||||
|
if(received > 0){
|
||||||
|
msg.append(std::string(inbuf));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (received < 0) {
|
||||||
TelldusCore::MutexLocker locker(&d->mutex);
|
TelldusCore::MutexLocker locker(&d->mutex);
|
||||||
d->connected = false;
|
d->connected = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string msg(inbuf);
|
|
||||||
return TelldusCore::charToWstring(msg.c_str());
|
return TelldusCore::charToWstring(msg.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue