Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
f97aa86e
Unverified
Commit
f97aa86e
authored
Apr 28, 2021
by
James Lamb
Committed by
GitHub
Apr 29, 2021
Browse files
show specific error message in TCP accept/send/receive logs (#4128)
parent
fa6d3565
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
+18
-3
src/network/socket_wrapper.hpp
src/network/socket_wrapper.hpp
+18
-3
No files found.
src/network/socket_wrapper.hpp
View file @
f97aa86e
...
...
@@ -267,7 +267,12 @@ class TcpSocket {
inline
TcpSocket
Accept
()
{
SOCKET
newfd
=
accept
(
sockfd_
,
NULL
,
NULL
);
if
(
newfd
==
INVALID_SOCKET
)
{
Log
::
Fatal
(
"Socket accept error, code: %d"
,
GetLastError
());
int
err_code
=
GetLastError
();
#if defined(_WIN32)
Log
::
Fatal
(
"Socket accept error (code: %d)"
,
err_code
);
#else
Log
::
Fatal
(
"Socket accept error, %s (code: %d)"
,
std
::
strerror
(
err_code
),
err_code
);
#endif
}
return
TcpSocket
(
newfd
);
}
...
...
@@ -275,7 +280,12 @@ class TcpSocket {
inline
int
Send
(
const
char
*
buf_
,
int
len
,
int
flag
=
0
)
{
int
cur_cnt
=
send
(
sockfd_
,
buf_
,
len
,
flag
);
if
(
cur_cnt
==
SOCKET_ERROR
)
{
Log
::
Fatal
(
"Socket send error, code: %d"
,
GetLastError
());
int
err_code
=
GetLastError
();
#if defined(_WIN32)
Log
::
Fatal
(
"Socket send error (code: %d)"
,
err_code
);
#else
Log
::
Fatal
(
"Socket send error, %s (code: %d)"
,
std
::
strerror
(
err_code
),
err_code
);
#endif
}
return
cur_cnt
;
}
...
...
@@ -283,7 +293,12 @@ class TcpSocket {
inline
int
Recv
(
char
*
buf_
,
int
len
,
int
flags
=
0
)
{
int
cur_cnt
=
recv
(
sockfd_
,
buf_
,
len
,
flags
);
if
(
cur_cnt
==
SOCKET_ERROR
)
{
Log
::
Fatal
(
"Socket recv error, code: %d"
,
GetLastError
());
int
err_code
=
GetLastError
();
#if defined(_WIN32)
Log
::
Fatal
(
"Socket recv error (code: %d)"
,
err_code
);
#else
Log
::
Fatal
(
"Socket recv error, %s (code: %d)"
,
std
::
strerror
(
err_code
),
err_code
);
#endif
}
return
cur_cnt
;
}
...
...
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