Fixed so that receiving socket has no buffer limit when reading in Windows. Closes #145.
This commit is contained in:
parent
24586433d9
commit
81671d1607
1 changed files with 40 additions and 29 deletions
|
@ -93,10 +93,14 @@ std::wstring Socket::read(int timeout){
|
|||
d->readEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
|
||||
oOverlap.hEvent = d->readEvent;
|
||||
BOOL fSuccess = false;
|
||||
std::wstring returnString;
|
||||
bool moreData = true;
|
||||
|
||||
memset(&buf, 0, BUFSIZE);
|
||||
while(moreData){
|
||||
moreData = false;
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
|
||||
ReadFile( d->hPipe, &buf, sizeof(wchar_t)*BUFSIZE, &cbBytesRead, &oOverlap);
|
||||
ReadFile( d->hPipe, &buf, sizeof(buf)-sizeof(wchar_t), &cbBytesRead, &oOverlap);
|
||||
|
||||
result = WaitForSingleObject(oOverlap.hEvent, timeout);
|
||||
|
||||
|
@ -114,21 +118,28 @@ std::wstring Socket::read(int timeout){
|
|||
return L"";
|
||||
}
|
||||
fSuccess = GetOverlappedResult(d->hPipe, &oOverlap, &cbBytesRead, false);
|
||||
|
||||
if (!fSuccess) {
|
||||
DWORD err = GetLastError();
|
||||
|
||||
//debuglog(result, "This then?");
|
||||
//debuglog(1, "Unsuccessful");
|
||||
|
||||
if(err == ERROR_MORE_DATA){
|
||||
moreData = true;
|
||||
}
|
||||
else{
|
||||
buf[0] = 0;
|
||||
}
|
||||
if (err == ERROR_BROKEN_PIPE) {
|
||||
//debuglog(1, "Broken pipe");
|
||||
d->connected = false;
|
||||
}
|
||||
buf[0] = 0;
|
||||
}
|
||||
|
||||
returnString.append(buf);
|
||||
}
|
||||
CancelIo(d->hPipe);
|
||||
CloseHandle(d->readEvent);
|
||||
return buf;
|
||||
return returnString;
|
||||
}
|
||||
|
||||
void Socket::write(const std::wstring &msg){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue