diff --git a/src/common/channel.cpp b/src/common/channel.cpp index fa9a801a273142eaaec3637b55b326649c1c353f..08558720b6883379fe74d543f6e59250e4ad8a21 100644 --- a/src/common/channel.cpp +++ b/src/common/channel.cpp @@ -129,9 +129,20 @@ void HdcChannelBase::ReadStream(uv_stream_t *tcp, ssize_t nread, const uv_buf_t if (hChannel->availTailIndex - DWORD_SERIALIZE_SIZE < size) { break; } - if (thisClass->ReadChannel(hChannel, (uint8_t *)hChannel->ioBuf + DWORD_SERIALIZE_SIZE + indexBuf, size) < 0) { - needExit = true; - break; + + if (!strncmp((char *)hChannel->ioBuf + DWORD_SERIALIZE_SIZE, LONG_CONN_MESSAGE.c_str(), LONG_CONN_MESSAGE.size())) { //HLONG is need long connect + if (thisClass->ReadChannel(hChannel, (uint8_t *)hChannel->ioBuf + LONG_CONN_MESSAGE.size() + DWORD_SERIALIZE_SIZE + indexBuf, size) < 0) { + // update io + hChannel->availTailIndex -= (DWORD_SERIALIZE_SIZE + size); + indexBuf += DWORD_SERIALIZE_SIZE + size; + needExit = false; // keep connect + break; + } + } else { + if (thisClass->ReadChannel(hChannel, (uint8_t *)hChannel->ioBuf + DWORD_SERIALIZE_SIZE + indexBuf, size) < 0) { + needExit = true; + break; + } } // update io hChannel->availTailIndex -= (DWORD_SERIALIZE_SIZE + size); @@ -427,4 +438,4 @@ HChannel HdcChannelBase::AdminChannel(const uint8_t op, const uint32_t channelId } return hRet; } -} \ No newline at end of file +} diff --git a/src/common/define.h b/src/common/define.h index 7b1f6396c42872e158383b9adc951a9f5f55ab22..495660d62605997283fed09379d2eeed058eabfc 100644 --- a/src/common/define.h +++ b/src/common/define.h @@ -54,6 +54,7 @@ const string UT_TMP_PATH = "/tmp/hdc-ut"; const string SERVER_NAME = "HDCServer"; const string STRING_EMPTY = ""; const string HANDSHAKE_MESSAGE = "OHOS HDC"; // sep not char '-', not more than 11 bytes +const string LONG_CONN_MESSAGE = "HLONG"; // long socket connect flag const string PACKET_FLAG = "HW"; // must 2bytes const string EMPTY_ECHO = "[Empty]"; const string MESSAGE_INFO = "[Info]";