Timeout not infinite for client reads after sending
This commit is contained in:
parent
48a055a061
commit
8da5bf1ae5
3 changed files with 7 additions and 2 deletions
|
@ -167,7 +167,7 @@ std::wstring Client::sendToService(const Message &msg) {
|
|||
s.connect(L"TelldusClient");
|
||||
s.write(msg.data());
|
||||
|
||||
return s.read();
|
||||
return s.read(500);
|
||||
}
|
||||
|
||||
void Client::stopThread(){
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace TelldusCore {
|
|||
void connect(const std::wstring &server);
|
||||
bool isConnected();
|
||||
std::wstring read();
|
||||
std::wstring read(int timeout);
|
||||
void stopReadWait();
|
||||
void write(const std::wstring &msg);
|
||||
|
||||
|
|
|
@ -78,6 +78,10 @@ void Socket::stopReadWait(){
|
|||
}
|
||||
|
||||
std::wstring Socket::read() {
|
||||
return read(INFINITE);
|
||||
}
|
||||
|
||||
std::wstring Socket::read(int timeout){
|
||||
wchar_t buf[BUFSIZE];
|
||||
int result;
|
||||
DWORD cbBytesRead = 0;
|
||||
|
@ -91,7 +95,7 @@ std::wstring Socket::read() {
|
|||
|
||||
ReadFile( d->hPipe, &buf, sizeof(wchar_t)*BUFSIZE, &cbBytesRead, &oOverlap);
|
||||
|
||||
result = WaitForSingleObject(oOverlap.hEvent, INFINITE);
|
||||
result = WaitForSingleObject(oOverlap.hEvent, timeout);
|
||||
|
||||
if(!d->running){
|
||||
CloseHandle(d->readEvent);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue