Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
familyMart_takeaway
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guanghui.cui
familyMart_takeaway
Commits
3f8c5797
Commit
3f8c5797
authored
May 22, 2018
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加接收message长度判断
parent
62ab5cfd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletions
+6
-1
src/SocketModule.cpp
+5
-0
src/main.cpp
+1
-1
No files found.
src/SocketModule.cpp
View file @
3f8c5797
...
@@ -219,6 +219,11 @@ bool TCPClient::receive(std::string &message)
...
@@ -219,6 +219,11 @@ bool TCPClient::receive(std::string &message)
}
}
//然后读取数据部分
//然后读取数据部分
unsigned
int
lenHost
=
ntohl
(
buf
.
msgLen
);
unsigned
int
lenHost
=
ntohl
(
buf
.
msgLen
);
if
(
lenHost
>
FM_BUF_SIZE
)
{
//如果数据长度大于最大可接收范围,返回false
LOG
(
INFO
)
<<
"Out of maximum range,message length:"
<<
lenHost
;
return
false
;
}
readBytes
=
readn
(
m_sockfd
,
buf
.
text
,
lenHost
);
readBytes
=
readn
(
m_sockfd
,
buf
.
text
,
lenHost
);
if
(
readBytes
==
(
size_t
)
-
1
)
if
(
readBytes
==
(
size_t
)
-
1
)
{
{
...
...
src/main.cpp
View file @
3f8c5797
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
INITIALIZE_EASYLOGGINGPP
INITIALIZE_EASYLOGGINGPP
#define VERSION "1.0.
5
" //版本号
#define VERSION "1.0.
4.1
" //版本号
std
::
string
g_init_data
;
std
::
string
g_init_data
;
std
::
string
g_init_data_ods_back
;
std
::
string
g_init_data_ods_back
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment