Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
FreemudAPI
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
zhenfei.zhang
FreemudAPI
Commits
de68aeab
Commit
de68aeab
authored
Nov 24, 2017
by
NitefullWind
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 修复日志太长时崩溃Bug。
parent
e6642d71
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
11 deletions
+11
-11
FreemudAPI/FreemudAPI.aps
+0
-0
FreemudAPI/FreemudAPI.cpp
+4
-4
FreemudAPI/FreemudAPI.rc
+0
-0
FreemudAPI/recv.h
+5
-5
FreemudAPI/send.h
+1
-1
FreemudAPI/stdafx.h
+1
-1
No files found.
FreemudAPI/FreemudAPI.aps
View file @
de68aeab
No preview for this file type
FreemudAPI/FreemudAPI.cpp
View file @
de68aeab
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
strset(ErrorMsg, 0); \
strset(ErrorMsg, 0); \
sprintf(ErrorMsg, msg, __VA_ARGS__); \
sprintf(ErrorMsg, msg, __VA_ARGS__); \
_error = Freemud::Error(FM_ERROR_CODE_SOCKET, ErrorMsg); \
_error = Freemud::Error(FM_ERROR_CODE_SOCKET, ErrorMsg); \
L
og(ErrorMsg);
\
L
OG() << ErrorMsg;
\
isOk = false;
isOk = false;
extern
"C"
{
extern
"C"
{
...
@@ -31,7 +31,7 @@ extern "C" {
...
@@ -31,7 +31,7 @@ extern "C" {
bool
isOk
=
true
;
bool
isOk
=
true
;
Freemud
::
Error
_error
;
Freemud
::
Error
_error
;
char
ErrorMsg
[
1000
]
=
{
0
};
char
ErrorMsg
[
2048
]
=
{
0
};
//Log("Initialising Winsock...");
//Log("Initialising Winsock...");
if
(
WSAStartup
(
MAKEWORD
(
2
,
2
),
&
wsa
)
!=
0
)
if
(
WSAStartup
(
MAKEWORD
(
2
,
2
),
&
wsa
)
!=
0
)
...
@@ -62,7 +62,7 @@ extern "C" {
...
@@ -62,7 +62,7 @@ extern "C" {
MakeError
(
"Error. Send error: %d. Server: %s, Port: %d"
,
WSAGetLastError
(),
SERVERIP
,
SERVERPORT
)
MakeError
(
"Error. Send error: %d. Server: %s, Port: %d"
,
WSAGetLastError
(),
SERVERIP
,
SERVERPORT
)
}
}
if
(
isOk
)
{
if
(
isOk
)
{
L
og
(
"Send data: %s"
,
req
)
;
L
OG
()
<<
"Send data: "
<<
req
;
}
}
int
recv_size
=
SOCKET_ERROR
;
int
recv_size
=
SOCKET_ERROR
;
...
@@ -81,7 +81,7 @@ extern "C" {
...
@@ -81,7 +81,7 @@ extern "C" {
}
}
if
(
isOk
)
{
if
(
isOk
)
{
L
og
(
"Recv size: %d, Recv data: %s"
,
recv_size
,
rsp
)
;
L
OG
()
<<
"Recv size: "
<<
recv_size
<<
" Recv data: "
<<
rsp
;
}
else
if
(
_error
.
Code
()
==
FM_ERROR_CODE_SOCKET
)
{
}
else
if
(
_error
.
Code
()
==
FM_ERROR_CODE_SOCKET
)
{
sprintf
(
ErrorMsg
,
"{
\"
statusCode
\"
: 104,
\"
msg
\"
:
\"
本地Socket通讯错误(%s).
\"
}"
,
_error
.
Msg
().
c_str
());
sprintf
(
ErrorMsg
,
"{
\"
statusCode
\"
: 104,
\"
msg
\"
:
\"
本地Socket通讯错误(%s).
\"
}"
,
_error
.
Msg
().
c_str
());
strcpy
(
rsp
,
ErrorMsg
);
strcpy
(
rsp
,
ErrorMsg
);
...
...
FreemudAPI/FreemudAPI.rc
View file @
de68aeab
No preview for this file type
FreemudAPI/recv.h
View file @
de68aeab
...
@@ -9,16 +9,16 @@ int _Recv(SOCKET socket, char *ptr, int length)
...
@@ -9,16 +9,16 @@ int _Recv(SOCKET socket, char *ptr, int length)
do
{
do
{
if
(
(
totalLen
=
recv
(
socket
,
ptr
,
length
,
0
))
<
0
)
{
if
(
(
totalLen
=
recv
(
socket
,
ptr
,
length
,
0
))
<
0
)
{
if
(
totalLen
==
EINTR
)
{
if
(
totalLen
==
EINTR
)
{
L
og
(
"Error: EINTR."
)
;
L
OG
()
<<
"Error: EINTR."
;
continue
;
continue
;
}
}
L
og
(
"Error: other recv error."
)
;
L
OG
()
<<
"Error: other recv error."
;
return
totalLen
;
return
totalLen
;
}
else
if
(
totalLen
==
0
)
{
}
else
if
(
totalLen
==
0
)
{
L
og
(
"Error: connect closed."
)
;
L
OG
()
<<
"Error: connect closed."
;
return
0
;
return
0
;
}
}
L
og
(
"Total: Size:%d, Data:%s"
,
totalLen
,
ptr
)
;
L
OG
()
<<
"Total: Size: "
<<
totalLen
<<
" Data: "
<<
ptr
;
}
while
(
0
);
}
while
(
0
);
return
totalLen
;
return
totalLen
;
...
@@ -67,7 +67,7 @@ int Recv(SOCKET socket, char *ptr, unsigned int byteSize)
...
@@ -67,7 +67,7 @@ int Recv(SOCKET socket, char *ptr, unsigned int byteSize)
}
}
if
(
byteSize
<
dataLen
)
{
// 判断接收Buffer长度是否足够
if
(
byteSize
<
dataLen
)
{
// 判断接收Buffer长度是否足够
L
og
(
"Error. Buffer overflow, Except size: %d, Actual size: %d"
,
byteSize
,
dataLen
)
;
L
OG
()
<<
"Error. Buffer overflow, Except size: "
<<
byteSize
<<
" Actual size: "
<<
dataLen
;
delete
[]
recvBuf
;
delete
[]
recvBuf
;
delete
[]
tempBuf
;
delete
[]
tempBuf
;
return
FMError_BufferOverflow
.
Code
();
return
FMError_BufferOverflow
.
Code
();
...
...
FreemudAPI/send.h
View file @
de68aeab
...
@@ -16,7 +16,7 @@ int Send(SOCKET socket, const char *ptr)
...
@@ -16,7 +16,7 @@ int Send(SOCKET socket, const char *ptr)
#endif
#endif
int
tempLen
=
-
1
;
int
tempLen
=
-
1
;
if
(
(
tempLen
=
send
(
socket
,
sendData
,
sendLength
,
0
))
<
0
)
{
if
(
(
tempLen
=
send
(
socket
,
sendData
,
sendLength
,
0
))
<
0
)
{
L
og
(
"Error: other error."
)
;
L
OG
()
<<
"Error: other error."
;
}
}
#ifdef NeedSocketHeaderSend
#ifdef NeedSocketHeaderSend
...
...
FreemudAPI/stdafx.h
View file @
de68aeab
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
#include "fm_log.h"
#include "fm_log.h"
//#define Log(_Format, ...) {char msg[1024] = {0}; printf("Function:%s, Line:%d: ", __FUNCTION__, __LINE__); printf(_Format, __VA_ARGS__); printf("\n");}
//#define Log(_Format, ...) {char msg[1024] = {0}; printf("Function:%s, Line:%d: ", __FUNCTION__, __LINE__); printf(_Format, __VA_ARGS__); printf("\n");}
#define Log(_Format, ...) {char msg[1024
] = {0};sprintf(msg, _Format, __VA_ARGS__);LOG() << msg;}
//#define Log(_Format, ...) {char msg[20480
] = {0};sprintf(msg, _Format, __VA_ARGS__);LOG() << msg;}
const
int
MAX_SIZE
=
4096
;
const
int
MAX_SIZE
=
4096
;
// 设置超时时间
// 设置超时时间
...
...
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